diff --git a/src/scripts/redirect/index.ts b/src/scripts/redirect/index.ts index ef79ff0..592fdaf 100644 --- a/src/scripts/redirect/index.ts +++ b/src/scripts/redirect/index.ts @@ -58,6 +58,7 @@ class App { } redirection &&= this.#ensure(redirection.trim()) + redirection &&= this.#normalize(redirection) return redirection } @@ -74,6 +75,17 @@ class App { } return url } + + #normalize(url: string): Location['href'] { + try { + const urlObj = new URL(url) + urlObj.pathname = urlObj.pathname.replace(/\/+/g, '/') + return urlObj.href + } catch (error) { + warn(error) + return url + } + } } new App(sites).boot()