Skip to content

Commit

Permalink
Links are parsed incorrectly when Ctrl+clicked (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeschli authored Feb 26, 2024
1 parent 81cf18f commit 6b384d3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/services/htmlLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/test/links.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ suite('HTML Link Detection', () => {
testLinkDetection('<link rel="icon" type="image/x-icon" href="data:@file/x-icon;base64,AAABAAIAQEAAAAEAIAAoQgAAJgA">', []);
testLinkDetection('<blockquote cite="foo.png">', [{ offset: 18, length: 7, target: 'file:///test/data/abc/foo.png' }]);
testLinkDetection('<style src="styles.css?t=345">', [{ offset: 12, length: 16, target: 'file:///test/data/abc/styles.css' }]);
testLinkDetection('<a href="https://werkenvoor.be/nl/jobs?f%5B0%5D=activitydomains%3A115&f%5B1%5D=lang%3Anl">link</a>', [{ offset: 9, length: 79, target: 'https://werkenvoor.be/nl/jobs?f%5B0%5D=activitydomains%3A115&f%5B1%5D=lang%3Anl' }]);
});

test('Local targets', () => {
Expand Down

0 comments on commit 6b384d3

Please sign in to comment.