Skip to content

Commit 1de3be4

Browse files
committed
fix: href
1 parent e543c3e commit 1de3be4

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

docs/.vitepress/plugins/mirror.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,12 @@ export const transformHtml = (code: string) => {
188188
const rewriteAppendChild = (base: string) => {
189189
const rawAppendChild = Node.prototype.appendChild;
190190
Node.prototype.appendChild = function <T extends Node>(node: T): T {
191-
if (
192-
node instanceof HTMLLinkElement &&
193-
node.rel === 'prefetch' &&
194-
node.href.startsWith('/assets/')
195-
) {
196-
node.href = base + node.href;
191+
if (node instanceof HTMLLinkElement && node.rel === 'prefetch') {
192+
const href = node.getAttribute('href');
193+
if (href && href.startsWith('/assets/')) {
194+
node.href = base + href;
195+
}
197196
}
198-
return rawAppendChild.call(this, node) as T
197+
return rawAppendChild.call(this, node) as T;
199198
};
200199
};

0 commit comments

Comments
 (0)