Implement protocol validation

This commit is contained in:
RyotaK
2022-12-16 16:50:57 +00:00
parent 8636d0f820
commit cb8d93a1ef
+19 -8
View File
@@ -66,14 +66,25 @@ export class OscLinkProvider implements ILinkProvider {
y y
} }
}; };
// OSC links always use underline and pointer decorations
result.push({ let ignoreLink = false;
text, if (!linkHandler?.allowNonHttpProtocols) {
range, const parsed = new URL(text);
activate: (e, text) => (linkHandler ? linkHandler.activate(e, text, range) : defaultActivate(e, text)), if (!['http:', 'https:'].includes(parsed.protocol)) {
hover: (e, text) => linkHandler?.hover?.(e, text, range), ignoreLink = true;
leave: (e, text) => linkHandler?.leave?.(e, text, range) }
}); }
if (!ignoreLink) {
// OSC links always use underline and pointer decorations
result.push({
text,
range,
activate: (e, text) => (linkHandler ? linkHandler.activate(e, text, range) : defaultActivate(e, text)),
hover: (e, text) => linkHandler?.hover?.(e, text, range),
leave: (e, text) => linkHandler?.leave?.(e, text, range)
});
}
} }
finishLink = false; finishLink = false;