Fix getObjectByLocation (zoom download issue)

This commit is contained in:
Alexey Safronov 2024-04-17 20:10:04 +04:00
parent 8a2bd2c465
commit a16f9e1c80
2 changed files with 12 additions and 29 deletions

View File

@ -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 {};
}
}

View File

@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
@ -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) {