diff --git a/src/utils/tooltipify.tsx b/src/utils/tooltipify.tsx index afdcf29609..843ee326ab 100644 --- a/src/utils/tooltipify.tsx +++ b/src/utils/tooltipify.tsx @@ -47,12 +47,17 @@ export function tooltipifyLinks(rootNodes: ArrayLike, ignoredNodes: Ele if (node.tagName === "A" && node.getAttribute("href") && node.getAttribute("href") !== node.textContent.trim() ) { - const href = node.getAttribute("href"); + let href = node.getAttribute("href"); + try { + href = new URL(href, window.location.href).toString(); + } catch (e) { + // Not all hrefs will be valid URLs + } // The node's innerHTML was already sanitized before being rendered in the first place, here we are just // wrapping the link with the LinkWithTooltip component, keeping the same children. Ideally we'd do this // without the superfluous span but this is not something React trivially supports at this time. - const tooltip = + const tooltip = ;