From 46adb3596669f1d65186768093680d9df05fb2ca Mon Sep 17 00:00:00 2001 From: Anton Bulakh Date: Mon, 30 Dec 2024 19:55:18 +0200 Subject: [PATCH] fix(spa): Normalize empty hrefs (#1695) A final breadcrumb has an empty href, linking to the current page, but the relative url normalization method missed those, making the link appear broken in search previews and popovers. Fixes #1690 --- quartz/util/path.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quartz/util/path.ts b/quartz/util/path.ts index c02bfb1..a6a05f9 100644 --- a/quartz/util/path.ts +++ b/quartz/util/path.ts @@ -108,10 +108,10 @@ const _rebaseHtmlElement = (el: Element, attr: string, newBase: string | URL) => el.setAttribute(attr, rebased.pathname + rebased.hash) } export function normalizeRelativeURLs(el: Element | Document, destination: string | URL) { - el.querySelectorAll('[href^="./"], [href^="../"]').forEach((item) => + el.querySelectorAll('[href=""], [href^="./"], [href^="../"]').forEach((item) => _rebaseHtmlElement(item, "href", destination), ) - el.querySelectorAll('[src^="./"], [src^="../"]').forEach((item) => + el.querySelectorAll('[src=""], [src^="./"], [src^="../"]').forEach((item) => _rebaseHtmlElement(item, "src", destination), ) }