Skip to content

Commit 9fcc137

Browse files
committed
avoid rewriting external and root-relative URLs in rewriteRelativeLink
1 parent 903c5d2 commit 9fcc137

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/pages/_utils-node.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ export const rewriteRelativeLink = (url: string): string => {
4848
let updatedUrl: string = url;
4949

5050
if (/^(https?:|mailto:|\/\/)/.exec(url)) {
51-
// Leave external URLs alone
51+
// Skip rewriting for external URLs (http(s), mailto)
5252
return url;
53-
} else if (url.startsWith('#')) {
54-
// Leave links to headings alone
53+
} else if (url.startsWith('#')||url.startsWith('/')) {
54+
// Skip rewriting for heading links and root-relative internal paths
5555
updatedUrl = url;
5656
} else {
5757
// Convert relative paths to '../' (because pages that started as files in the same directory

0 commit comments

Comments
 (0)