From a16f9e1c80ed6bfed498a8db2a2e49ee9b28fa2f Mon Sep 17 00:00:00 2001 From: Alexey Safronov Date: Wed, 17 Apr 2024 20:10:04 +0400 Subject: [PATCH] Fix getObjectByLocation (zoom download issue) --- packages/shared/utils/common.ts | 18 +++--------------- public/thirdparty/third-party.html | 23 +++++++++-------------- 2 files changed, 12 insertions(+), 29 deletions(-) diff --git a/packages/shared/utils/common.ts b/packages/shared/utils/common.ts index 93be081861..aaa05cfb20 100644 --- a/packages/shared/utils/common.ts +++ b/packages/shared/utils/common.ts @@ -906,22 +906,10 @@ export function getObjectByLocation(location: Location) { try { const searchUrl = location.search.substring(1); - const decodedString = decodeURIComponent(searchUrl) - .replace(/\["/g, '["') - .replace(/"\]/g, '"]') - .replace(/"/g, '\\"') - .replace(/&/g, '","') - .replace(/=/g, '":"') - .replace(/\\/g, "\\\\") - .replace(/\[\\\\"/g, '["') - .replace(/\\\\"\]/g, '"]') - .replace(/"\[/g, "[") - .replace(/\]"/g, "]") - .replace(/\\\\",\\\\"/g, '","') - .replace(/\\\\\\\\"/g, '\\"'); - const object = JSON.parse(`{"${decodedString}"}`); - return object; + const params = Object.fromEntries(new URLSearchParams(searchUrl)); + return params; } catch (e) { + console.error(e); return {}; } } diff --git a/public/thirdparty/third-party.html b/public/thirdparty/third-party.html index 3f80525ba2..ce84948f08 100644 --- a/public/thirdparty/third-party.html +++ b/public/thirdparty/third-party.html @@ -1,4 +1,4 @@ - + @@ -49,19 +49,14 @@ function getObjectByLocation(location) { if (!location.search || !location.search.length) return null; - const searchUrl = location.search.substring(1); - const object = JSON.parse( - '{"' + - decodeURIComponent( - searchUrl - .replace(/"/g, '\\"') - .replace(/&/g, '","') - .replace(/=/g, '":"') - ) + - '"}' - ); - - return object; + try { + const searchUrl = location.search.substring(1); + const params = Object.fromEntries(new URLSearchParams(searchUrl)); + return params; + } catch (e) { + console.error(e); + return {}; + } } function renderError(error) {