Skip to content

Commit 903c5d2

Browse files
committed
avoid adding trailing slash to external URLs in contributor-docs build
1 parent 5e82f3b commit 903c5d2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/pages/_utils-node.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ export const removeNestedReferencePaths = (route: string): string =>
4545
route.replace(/constants\/|types\//, "")
4646

4747
export const rewriteRelativeLink = (url: string): string => {
48-
let updatedUrl: string;
48+
let updatedUrl: string = url;
4949

50-
if (/^((https?:\/)?)\//.exec(url) || url.startsWith('mailto:')) {
51-
// Leave absolute paths alone
52-
updatedUrl = url;
50+
if (/^(https?:|mailto:|\/\/)/.exec(url)) {
51+
// Leave external URLs alone
52+
return url;
5353
} else if (url.startsWith('#')) {
5454
// Leave links to headings alone
5555
updatedUrl = url;
@@ -81,4 +81,4 @@ export const rewriteRelativeLink = (url: string): string => {
8181
}
8282

8383
return updatedUrl;
84-
};
84+
};

0 commit comments

Comments
 (0)