From 9984ea507418b6750000a00e4e9d2aeb66f6c089 Mon Sep 17 00:00:00 2001 From: Andy Hsu Date: Fri, 1 Mar 2024 19:26:12 +0800 Subject: [PATCH] fix: don't use `String.prototype.replaceAll` --- src/utils/path.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/utils/path.ts b/src/utils/path.ts index dfd7e679b6..bc4a2885cf 100644 --- a/src/utils/path.ts +++ b/src/utils/path.ts @@ -41,14 +41,13 @@ export const encodePath = (path: string, all?: boolean) => { return path .split("/") .map((p) => - // ["#", "?", "%"].some((c) => p.includes(c)) ? encodeURIComponent(p) : p all ? encodeURIComponent(p) : p - .replaceAll("%", "%25") - .replaceAll("?", "%3F") - .replaceAll("#", "%23") - .replaceAll(" ", "%20"), + .replace(/%/g, "%25") + .replace(/\?/g, "%3F") + .replace(/#/g, "%23") + .replace(/ /g, "%20"), ) .join("/") }