From 049a7834fd8320c9731a7580524347121a61590d Mon Sep 17 00:00:00 2001 From: cyfung1031 <44498510+cyfung1031@users.noreply.github.com> Date: Thu, 20 Nov 2025 16:19:34 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[v1.3]=20=E8=AE=A9=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2URL=E5=A5=BD=E7=9C=8B=E4=B8=80=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/install/App.tsx | 6 +++--- src/pkg/utils/utils.ts | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/pages/install/App.tsx b/src/pages/install/App.tsx index ee282d963..d39fbfd93 100644 --- a/src/pages/install/App.tsx +++ b/src/pages/install/App.tsx @@ -31,7 +31,7 @@ import { intervalExecution, timeoutExecution } from "@App/pkg/utils/timer"; import { useSearchParams } from "react-router-dom"; import { CACHE_KEY_SCRIPT_INFO } from "@App/app/cache_key"; import { cacheInstance } from "@App/app/cache"; -import { formatBytes } from "@App/pkg/utils/utils"; +import { formatBytes, prettyUrl } from "@App/pkg/utils/utils"; type ScriptOrSubscribe = Script | Subscribe; @@ -779,13 +779,13 @@ function App() { bold style={{ overflowWrap: "break-word", - wordBreak: "break-all", + wordBreak: "break-word", maxHeight: "70px", display: "block", overflowY: "auto", }} > - {`${t("source")}: ${scriptInfo?.url}`} + {`${t("source")}: ${prettyUrl(scriptInfo?.url)}`} diff --git a/src/pkg/utils/utils.ts b/src/pkg/utils/utils.ts index e6e1b891b..4b3887ef7 100644 --- a/src/pkg/utils/utils.ts +++ b/src/pkg/utils/utils.ts @@ -439,3 +439,27 @@ export const formatBytes = (bytes: number, decimals: number = 2): string => { return `${value.toFixed(decimals)} ${units[i]}`; }; + +export const prettyUrl = (s: string | undefined | null, baseUrl?: string) => { + if (s?.includes("://")) { + let u; + try { + u = baseUrl ? new URL(s, baseUrl) : new URL(s); + } catch { + // ignored + } + if (!u) return s; + const pathname = u.pathname; + if (pathname && pathname.includes("%")) { + try { + const raw = decodeURI(pathname); + if (raw && raw.length < pathname.length) { + s = s.replace(pathname, decodeURI(pathname)); + } + } catch { + // ignored + } + } + } + return s; +}; From 110c60d32da7742f6fb07c24b402929afae3b7d8 Mon Sep 17 00:00:00 2001 From: cyfung1031 <44498510+cyfung1031@users.noreply.github.com> Date: Thu, 20 Nov 2025 16:44:44 +0900 Subject: [PATCH 2/3] Update utils.ts --- src/pkg/utils/utils.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/pkg/utils/utils.ts b/src/pkg/utils/utils.ts index 4b3887ef7..431752bf2 100644 --- a/src/pkg/utils/utils.ts +++ b/src/pkg/utils/utils.ts @@ -440,6 +440,7 @@ export const formatBytes = (bytes: number, decimals: number = 2): string => { return `${value.toFixed(decimals)} ${units[i]}`; }; +// 把编码URL变成使用者可以阅读的格式 export const prettyUrl = (s: string | undefined | null, baseUrl?: string) => { if (s?.includes("://")) { let u; @@ -453,8 +454,16 @@ export const prettyUrl = (s: string | undefined | null, baseUrl?: string) => { if (pathname && pathname.includes("%")) { try { const raw = decodeURI(pathname); - if (raw && raw.length < pathname.length) { - s = s.replace(pathname, decodeURI(pathname)); + if ( + raw && + raw.length < pathname.length && + !raw.includes("?") && + !raw.includes("#") && + !raw.includes("&") && + !raw.includes("=") && + !raw.includes("%") + ) { + s = s.replace(pathname, raw); } } catch { // ignored From d8cf0bce4a82d345969285bcef6c39748e2ca430 Mon Sep 17 00:00:00 2001 From: cyfung1031 <44498510+cyfung1031@users.noreply.github.com> Date: Thu, 20 Nov 2025 16:45:52 +0900 Subject: [PATCH 3/3] Update utils.ts --- src/pkg/utils/utils.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pkg/utils/utils.ts b/src/pkg/utils/utils.ts index 431752bf2..bb34c0a44 100644 --- a/src/pkg/utils/utils.ts +++ b/src/pkg/utils/utils.ts @@ -461,7 +461,8 @@ export const prettyUrl = (s: string | undefined | null, baseUrl?: string) => { !raw.includes("#") && !raw.includes("&") && !raw.includes("=") && - !raw.includes("%") + !raw.includes("%") && + !raw.includes(":") ) { s = s.replace(pathname, raw); }