fix: trim away trailing slash

This commit is contained in:
Christel Westerberg
2024-07-01 10:08:18 +02:00
parent fddee6b53f
commit 9b4fde334f
4 changed files with 19 additions and 3 deletions

View File

@@ -1,3 +1,11 @@
export function removeMultipleSlashes(str: string) {
return str.replaceAll(/\/\/+/g, "/")
}
export function removeTrailingSlash(pathname: string) {
if (pathname.endsWith("/")) {
// Remove the trailing slash
return pathname.slice(0, -1)
}
return pathname
}