Skip to content

Commit 46adb35

Browse files
authored
fix(spa): Normalize empty hrefs (jackyzha0#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 jackyzha0#1690
1 parent e1c9eab commit 46adb35

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

quartz/util/path.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ const _rebaseHtmlElement = (el: Element, attr: string, newBase: string | URL) =>
108108
el.setAttribute(attr, rebased.pathname + rebased.hash)
109109
}
110110
export function normalizeRelativeURLs(el: Element | Document, destination: string | URL) {
111-
el.querySelectorAll('[href^="./"], [href^="../"]').forEach((item) =>
111+
el.querySelectorAll('[href=""], [href^="./"], [href^="../"]').forEach((item) =>
112112
_rebaseHtmlElement(item, "href", destination),
113113
)
114-
el.querySelectorAll('[src^="./"], [src^="../"]').forEach((item) =>
114+
el.querySelectorAll('[src=""], [src^="./"], [src^="../"]').forEach((item) =>
115115
_rebaseHtmlElement(item, "src", destination),
116116
)
117117
}

0 commit comments

Comments
 (0)