1
>
/*---------------------------------------------------------------------------------------------
cliArgs.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
/**
7
>
* Rewrites `--folder-uri <uri>` / `--file-uri <uri>` pairs into a single
8
>
* `--flag=value` token so the URI is not a standalone argv entry. Used on
9
>
* Windows to avoid Chromium filtering URL-like tokens before main.js runs.
10
>
* See https://github.com/microsoft/vscode/issues/209072.
11
>
*/
12
>
export function combineUriFlags(args: string[]): string[] {
13
>
const result: string[] = [];
14
>
for (let i = 0; i < args.length; i++) {
15
>
const arg = args[i];
16
>
if (arg === '--') { // end-of-options marker: copy the rest verbatim
17
result.push(...args.slice(i));
18
break;
19
}
20
>
if ((arg === '--folder-uri' || arg === '--file-uri') && i + 1 < args.length && !args[i + 1].startsWith('-')) {
cliArgs.ts
21
result.push(`${arg}=${args[i + 1]}`);
22
i++; // skip the value, it's now part of the flag
24
>
result.push(arg);
25
>
}
26
>
}
27
>
return result;
28
>
}