From 581c4e27401783a99724b8f365033b0dfda1f131 Mon Sep 17 00:00:00 2001 From: akuuma <1919892171@qq.com> Date: Mon, 1 Dec 2025 17:58:56 +0800 Subject: [PATCH] Update index.ts --- src/scripts/redirect/index.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/scripts/redirect/index.ts b/src/scripts/redirect/index.ts index ef79ff00..592fdaf8 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()