Skip to content

Commit b3d3647

Browse files
committed
Properly handle errors from URL constructor
1 parent b07c016 commit b3d3647

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/browser/OscLinkProvider.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,13 @@ export class OscLinkProvider implements ILinkProvider {
6969

7070
let ignoreLink = false;
7171
if (!linkHandler?.allowNonHttpProtocols) {
72-
const parsed = new URL(text);
73-
if (!['http:', 'https:'].includes(parsed.protocol)) {
72+
try {
73+
const parsed = new URL(text);
74+
if (!['http:', 'https:'].includes(parsed.protocol)) {
75+
ignoreLink = true;
76+
}
77+
} catch (e) {
78+
// Ignore invalid URLs to prevent unexpected behaviors
7479
ignoreLink = true;
7580
}
7681
}

0 commit comments

Comments
 (0)