Properly handle errors from URL constructor

This commit is contained in:
RyotaK
2022-12-16 17:01:00 +00:00
parent b07c016fea
commit b3d36478ca
+7 -2
View File
@@ -69,8 +69,13 @@ export class OscLinkProvider implements ILinkProvider {
let ignoreLink = false;
if (!linkHandler?.allowNonHttpProtocols) {
const parsed = new URL(text);
if (!['http:', 'https:'].includes(parsed.protocol)) {
try {
const parsed = new URL(text);
if (!['http:', 'https:'].includes(parsed.protocol)) {
ignoreLink = true;
}
} catch (e) {
// Ignore invalid URLs to prevent unexpected behaviors
ignoreLink = true;
}
}