Implement protocol validation
This commit is contained in:
@@ -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;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user