| | |
| | | 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), |
| | | ) |
| | | } |
| | |
| | | |
| | | export function splitAnchor(link: string): [string, string] { |
| | | let [fp, anchor] = link.split("#", 2) |
| | | if (fp.endsWith(".pdf")) { |
| | | return [fp, anchor === undefined ? "" : `#${anchor}`] |
| | | } |
| | | anchor = anchor === undefined ? "" : "#" + slugAnchor(anchor) |
| | | return [fp, anchor] |
| | | } |