Anton Bulakh
2024-12-30 46adb3596669f1d65186768093680d9df05fb2ca
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
1 files modified
4 ■■■■ changed files
quartz/util/path.ts 4 ●●●● patch | view | raw | blame | history
quartz/util/path.ts
@@ -108,10 +108,10 @@
  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),
  )
}