From 6b384d3562388b5535acde3a96ef4cddeff2e51e Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Mon, 26 Feb 2024 16:52:27 +0100 Subject: [PATCH] Links are parsed incorrectly when Ctrl+clicked (#178) --- src/services/htmlLinks.ts | 3 ++- src/test/links.test.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/services/htmlLinks.ts b/src/services/htmlLinks.ts index ef075a4..7880189 100644 --- a/src/services/htmlLinks.ts +++ b/src/services/htmlLinks.ts @@ -83,7 +83,8 @@ function createLink(document: TextDocument, documentContext: DocumentContext, at function validateAndCleanURI(uriStr: string) : string | undefined { try { const uri = Uri.parse(uriStr); - if (uri.query) { + if (uri.scheme === 'file' && uri.query) { + // see https://github.com/microsoft/vscode/issues/194577 & https://github.com/microsoft/vscode/issues/206238 return uri.with({ query: null }).toString(/* skipEncodig*/ true); } return uriStr; diff --git a/src/test/links.test.ts b/src/test/links.test.ts index bc838eb..48d78a6 100644 --- a/src/test/links.test.ts +++ b/src/test/links.test.ts @@ -88,6 +88,7 @@ suite('HTML Link Detection', () => { testLinkDetection('', []); testLinkDetection('
', [{ offset: 18, length: 7, target: 'file:///test/data/abc/foo.png' }]); testLinkDetection('