From e52ef4522deb85280b19c9ac25695b2b0709405f Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 12 Sep 2022 15:28:22 +0100 Subject: [PATCH] Fix tile crash around tooltipify links (#9270) --- src/utils/tooltipify.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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 = ;