From 8e96f4d3de2519f374dc6d49d2fb2a68d859c33f Mon Sep 17 00:00:00 2001 From: Aaron Liu Date: Thu, 8 May 2025 19:17:25 +0800 Subject: [PATCH] fix(uri): hash tag is not properly handled in CrUri (https://github.com/cloudreve/Cloudreve/issues/2335) --- src/util/uri.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/util/uri.ts b/src/util/uri.ts index 576a3da..cfad823 100644 --- a/src/util/uri.ts +++ b/src/util/uri.ts @@ -196,11 +196,11 @@ export default class CrUri { } public path(): string { - return decodeURI(this.url.pathname); + return this.url.pathname; } public setPath(path: string): this { - this.url.pathname = encodeURI(path); + this.url.pathname = path; return this; } @@ -216,16 +216,18 @@ export default class CrUri { // path without leading slash public path_trimmed(): string { - return decodeURI(this.url.pathname).slice(1); + return this.url.pathname.slice(1); } public join(...paths: string[]): this { - this.url.pathname = path.join(this.url.pathname, ...paths.map((p) => encodeURI(p))); + this.url.pathname = path.join(this.url.pathname, ...paths.map((p) => encodeURIComponent(p))); return this; } public elements(): string[] { - const res = this.path_trimmed().split("/"); + const res = this.path_trimmed() + .split("/") + .map((p) => decodeURIComponent(p)); if (res.length == 1 && res[0] == "") { return []; }