From 471ef0e599a31df7125c167951eae1f8b68db9a8 Mon Sep 17 00:00:00 2001 From: johnsoncodehk Date: Mon, 29 Aug 2022 04:16:31 +0800 Subject: [PATCH] fix: component preview not working on windows close #1737 --- .../vscode-vue-language-features/src/features/preview.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/extensions/vscode-vue-language-features/src/features/preview.ts b/extensions/vscode-vue-language-features/src/features/preview.ts index dc62fa37d..83f443726 100644 --- a/extensions/vscode-vue-language-features/src/features/preview.ts +++ b/extensions/vscode-vue-language-features/src/features/preview.ts @@ -133,8 +133,8 @@ export async function register(context: vscode.ExtensionContext) { port = server.port; } - const relativePath = path.relative(path.dirname(configFile), fileName).replace(/\\\\\\\\/g, '/'); - let url = `http://localhost:${port}/__preview/${relativePath}#`; + const relativePath = shared.normalizeFileName(path.relative(path.dirname(configFile), fileName)); + let url = `http://localhost:${port}/__preview${relativePath}#`; if (lastPreviewDocument.isDirty) { url += btoa(lastPreviewDocument.getText()); @@ -407,8 +407,8 @@ export async function register(context: vscode.ExtensionContext) { } else if (previewType === PreviewType.ExternalBrowser_Component) { terminal.show(); - const relativePath = path.relative(path.dirname(configFile), fileName).replace(/\\\\\\\\/g, '/'); - panel.webview.html = getWebviewContent(`http://localhost:${port}/__preview/${relativePath}`, undefined, undefined, true); + const relativePath = shared.normalizeFileName(path.relative(path.dirname(configFile), fileName)); + panel.webview.html = getWebviewContent(`http://localhost:${port}/__preview${relativePath}`, undefined, undefined, true); externalBrowserPanel = panel; return; }