Skip to content

Commit 0d41d68

Browse files
committed
fix: use the more accurate logic
1 parent 5d96c39 commit 0d41d68

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

  • vscode-extensions/playwright-local-browser-server-vscode-extension/src

vscode-extensions/playwright-local-browser-server-vscode-extension/src/extension.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ async function writeExtensionInstalledFileAsync(terminal: ITerminal): Promise<vo
4242
// If on a remote environment, write a file to os.tempdir() using workspace fs
4343

4444
let fileUri: vscode.Uri;
45+
let tempDir: string;
4546

4647
if (vscode.env.remoteName) {
4748
const markerPrefix: string = '<<<TEMPDIR_START>>>';
@@ -52,10 +53,13 @@ async function writeExtensionInstalledFileAsync(terminal: ITerminal): Promise<vo
5253
terminal
5354
});
5455

55-
const tempDir: string = output.slice(
56-
output.indexOf(markerPrefix) + markerPrefix.length,
57-
output.indexOf(markerSuffix)
58-
);
56+
const startIndex: number = output.indexOf(markerPrefix);
57+
const endIndex: number = output.indexOf(markerSuffix);
58+
if (startIndex !== -1 && endIndex !== -1 && endIndex > startIndex) {
59+
tempDir = output.substring(startIndex + markerPrefix.length, endIndex).trim();
60+
} else {
61+
throw new Error('Failed to parse temp directory from command output');
62+
}
5963

6064
// For remote environments, use the vscode-remote scheme
6165
// The workspace folder should have the correct scheme already

0 commit comments

Comments
 (0)