Skip to content

Commit 1a02bd0

Browse files
committed
avoid double slashes in urls
1 parent 01ac557 commit 1a02bd0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/project/types/website/listing/website-listing-shared.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,11 @@ export const absoluteUrl = (siteUrl: string, url: string) => {
223223
if (url.startsWith("http:") || url.startsWith("https:")) {
224224
return url;
225225
} else {
226-
return `${siteUrl}/${url}`;
226+
const baseUrl = siteUrl.endsWith("/")
227+
? siteUrl.substring(0, siteUrl.length - 1)
228+
: siteUrl;
229+
const path = url.startsWith("/") ? url.substring(1, url.length) : url;
230+
return `${baseUrl}/${path}`;
227231
}
228232
};
229233

0 commit comments

Comments
 (0)