Skip to content

Commit 94f7a41

Browse files
committed
Add function to build command URI.
1 parent 9040525 commit 94f7a41

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

src/functions.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,18 +209,30 @@ export function commandLink({ command, project, title, body, query }:
209209
body: string;
210210
query: any;
211211
}): string {
212-
let uri = project.uri.with({
213-
scheme: "tsar",
214-
query: typeof query === 'string' ? query : JSON.stringify(query)
215-
});
216212
return `
217213
<a class="source-link"
218-
href="${encodeURI(
219-
`command:${command}?${encodeURIComponent(JSON.stringify(uri))}`)}"
214+
href="${commandRef({ command: command, project: project, query: query })}"
220215
title="${title}">
221216
${body}</a>`;
222217
}
223218

219+
/**
220+
* Return uri which invokes a specified command.
221+
* @param query String or JSON representation of command arguments.
222+
*/
223+
export function commandRef({ command, project, query }:
224+
{
225+
command: string;
226+
project: Project;
227+
query: any;
228+
}): string {
229+
let uri = project.uri.with({
230+
scheme: "tsar",
231+
query: typeof query === 'string' ? query : JSON.stringify(query)
232+
});
233+
return encodeURI(`command:${command}?${encodeURIComponent(JSON.stringify(uri))}`);
234+
}
235+
224236
/**
225237
* Return html representation of a link to a project.
226238
*

0 commit comments

Comments
 (0)