We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5e82f3b commit 903c5d2Copy full SHA for 903c5d2
src/pages/_utils-node.ts
@@ -45,11 +45,11 @@ export const removeNestedReferencePaths = (route: string): string =>
45
route.replace(/constants\/|types\//, "")
46
47
export const rewriteRelativeLink = (url: string): string => {
48
- let updatedUrl: string;
+ let updatedUrl: string = url;
49
50
- if (/^((https?:\/)?)\//.exec(url) || url.startsWith('mailto:')) {
51
- // Leave absolute paths alone
52
- updatedUrl = url;
+ if (/^(https?:|mailto:|\/\/)/.exec(url)) {
+ // Leave external URLs alone
+ return url;
53
} else if (url.startsWith('#')) {
54
// Leave links to headings alone
55
updatedUrl = url;
@@ -81,4 +81,4 @@ export const rewriteRelativeLink = (url: string): string => {
81
}
82
83
return updatedUrl;
84
-};
+};
0 commit comments