From 000f1407f2401b9f162bd3246526e695382c8a97 Mon Sep 17 00:00:00 2001 From: zWX1234017 Date: Tue, 3 Sep 2024 17:30:42 +0800 Subject: [PATCH] cherry pick d0bc60f from https://gitee.com/du-wei-zhao/commonlibrary_ets_utils/pulls/1381 url bugfix https://gitee.com/openharmony/commonlibrary_ets_utils/issues/IAOJG2 Signed-off-by: zWX1234017 --- js_api_module/url/src/js_url.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/js_api_module/url/src/js_url.ts b/js_api_module/url/src/js_url.ts index 2e1a1521..ecd15d69 100644 --- a/js_api_module/url/src/js_url.ts +++ b/js_api_module/url/src/js_url.ts @@ -591,15 +591,15 @@ class URL { this.host_ = encodeURI(nativeUrl.host); } this.hash_ = customEncodeURI(nativeUrl.hash, - {'%25': '%', '%7C': '|','%5B': '[','%5D': ']', '%7B': '{', '%7D': '}', '%60': '`',}); + {'%7C': '|', '%5B': '[', '%5D': ']', '%7B': '{', '%7D': '}', '%60': '`', '%25': '%'}); this.protocol_ = nativeUrl.protocol; - this.pathname_ = customEncodeURI(nativeUrl.pathname, {'%25': '%', '%7C': '|','%5B': '[','%5D': ']',}); + this.pathname_ = customEncodeURI(nativeUrl.pathname, {'%7C': '|', '%5B': '[', '%5D': ']', '%25': '%'}); this.port_ = nativeUrl.port; this.origin_ = nativeUrl.protocol + '//' + nativeUrl.host; this.searchParamsClass_ = new URLSearchParams(customEncodeURI(this.search_, - {'%25': '%', '%7C': '|','%5B': '[','%5D': ']', '%5E': '^',})); + {'%7C': '|', '%5B': '[', '%5D': ']', '%5E': '^', '%25': '%'})); this.URLParamsClass_ = new URLParams(customEncodeURI(this.search_, - {'%25': '%', '%7C': '|','%5B': '[','%5D': ']', '%5E': '^',})); + {'%7C': '|', '%5B': '[', '%5D': ']', '%5E': '^', '%25': '%'})); this.URLParamsClass_.parentUrl = this; this.searchParamsClass_.parentUrl = this; this.setHref(); @@ -644,15 +644,15 @@ class URL { urlHelper.host_ = encodeURI(nativeUrl.host); } urlHelper.hash_ = customEncodeURI(nativeUrl.hash, - {'%25': '%', '%7C': '|','%5B': '[','%5D': ']', '%7B': '{', '%7D': '}', '%60': '`',}); + {'%7C': '|', '%5B': '[', '%5D': ']', '%7B': '{', '%7D': '}', '%60': '`', '%25': '%'}); urlHelper.protocol_ = nativeUrl.protocol; - urlHelper.pathname_ = customEncodeURI(nativeUrl.pathname, {'%25': '%', '%7C': '|','%5B': '[','%5D': ']',}); + urlHelper.pathname_ = customEncodeURI(nativeUrl.pathname, {'%7C': '|', '%5B': '[', '%5D': ']', '%25': '%'}); urlHelper.port_ = nativeUrl.port; urlHelper.origin_ = nativeUrl.protocol + '//' + nativeUrl.host; urlHelper.searchParamsClass_ = new URLSearchParams(customEncodeURI(urlHelper.search_, - {'%25': '%', '%7C': '|','%5B': '[','%5D': ']', '%5E': '^',})); + {'%7C': '|', '%5B': '[', '%5D': ']', '%5E': '^', '%25': '%'})); urlHelper.URLParamsClass_ = new URLParams(customEncodeURI(urlHelper.search_, - {'%25': '%', '%7C': '|','%5B': '[','%5D': ']', '%5E': '^',})); + {'%7C': '|', '%5B': '[', '%5D': ']', '%5E': '^', '%25': '%'})); urlHelper.URLParamsClass_.parentUrl = urlHelper; urlHelper.searchParamsClass_.parentUrl = urlHelper; urlHelper.setHref(); @@ -727,7 +727,7 @@ class URL { } set hash(fragment) { const fragment_ = customEncodeURI(fragment, - {'%25': '%', '%7C': '|','%5B': '[','%5D': ']', '%7B': '{', '%7D': '}', '%60': '`',}); + {'%7C': '|', '%5B': '[', '%5D': ']', '%7B': '{', '%7D': '}', '%60': '`', '%25': '%'}); this.c_info.hash = fragment_; this.hash_ = this.c_info.hash; this.setHref(); @@ -799,9 +799,9 @@ class URL { this.host_ = encodeURI(this.c_info.host); } this.hash_ = customEncodeURI(this.c_info.hash, - {'%25': '%', '%7C': '|','%5B': '[','%5D': ']', '%7B': '{', '%7D': '}', '%60': '`',}); + {'%7C': '|', '%5B': '[', '%5D': ']', '%7B': '{', '%7D': '}', '%60': '`', '%25': '%'}); this.protocol_ = this.c_info.protocol; - this.pathname_ = customEncodeURI(this.c_info.pathname, {'%25': '%', '%7C': '|','%5B': '[','%5D': ']',}); + this.pathname_ = customEncodeURI(this.c_info.pathname, {'%7C': '|', '%5B': '[', '%5D': ']', '%25': '%'}); this.port_ = this.c_info.port; this.origin_ = this.protocol_ + '//' + this.host_; this.searchParamsClass_.updateParams(this.search_); @@ -814,7 +814,7 @@ class URL { return this.pathname_; } set pathname(path) { - const path_ = customEncodeURI(path, {'%25': '%', '%7C': '|','%5B': '[','%5D': ']',}); + const path_ = customEncodeURI(path, {'%7C': '|', '%5B': '[', '%5D': ']', '%25': '%'}); this.c_info.pathname = path_; this.pathname_ = this.c_info.pathname; this.setHref();