From 7e32f4b18f6fd55fd02ab5250c4a5187ae3808e8 Mon Sep 17 00:00:00 2001 From: Tomasz Subik Date: Fri, 24 May 2024 15:42:39 +0200 Subject: [PATCH] remove query-string --- package.json | 1 - utils/url.js | 10 +++++----- yarn.lock | 30 ------------------------------ 3 files changed, 5 insertions(+), 36 deletions(-) diff --git a/package.json b/package.json index f0f4d6b1..d9a529d4 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,6 @@ "next-redux-wrapper": "^4.0.1", "normalize.css": "^8.0.1", "prop-types": "^15.8.1", - "query-string": "6", "rc-tooltip": "6.2.0", "react": "17", "react-datepicker": "^4.11.0", diff --git a/utils/url.js b/utils/url.js index b5ad7bd5..9928060a 100644 --- a/utils/url.js +++ b/utils/url.js @@ -1,21 +1,21 @@ import Router from 'next/router'; -import qs from 'query-string'; export function setUrlParam(param, value) { const location = { pathname: Router.router.pathname, query: Router.router.query }; - const query = qs.parse(window.location.search); + const query = new URLSearchParams(window.location.search); if (value !== null && value !== undefined) { - query[param] = value; + query.set(param, value); location.query[param] = value; } else { - delete query[param]; + query.delete(param); delete location.query[param]; } - const as = qs.stringifyUrl({ url: window.location.pathname, query }); + const queryString = query.toString(); + const as = window.location.pathname + (queryString ? `?${queryString}` : ''); Router.push(location, as, { shallow: true, scroll: false }); } diff --git a/yarn.lock b/yarn.lock index 72e0fd87..9b93aec1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1878,11 +1878,6 @@ deck.gl@7.3.6: "@deck.gl/mesh-layers" "7.3.6" "@deck.gl/react" "7.3.6" -decode-uri-component@^0.2.0: - version "0.2.2" - resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.2.tgz#e69dbe25d37941171dd540e024c444cd5188e1e9" - integrity sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ== - deep-is@^0.1.3: version "0.1.4" resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.4.tgz#a6f2dce612fadd2ef1f519b73551f17e85199831" @@ -2502,11 +2497,6 @@ fill-range@^7.1.1: dependencies: to-regex-range "^5.0.1" -filter-obj@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/filter-obj/-/filter-obj-1.1.0.tgz#9b311112bc6c6127a16e016c6c5d7f19e0805c5b" - integrity sha512-8rXg1ZnX7xzy2NGDVkBVaAy+lSlPNwad13BtgSlLuxfIslyt5Vg64U7tFcCt4WS1R0hvtnQybT/IyCkGZ3DpXQ== - finalhandler@1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.2.0.tgz#7d23fe5731b207b4640e4fcd00aec1f9207a7b32" @@ -3926,16 +3916,6 @@ qs@6.11.0: dependencies: side-channel "^1.0.4" -query-string@6: - version "6.14.1" - resolved "https://registry.yarnpkg.com/query-string/-/query-string-6.14.1.tgz#7ac2dca46da7f309449ba0f86b1fd28255b0c86a" - integrity sha512-XDxAeVmpfu1/6IjyT/gXHOl+S0vQ9owggJ30hhWKdHAsNPOcasn5o9BW0eejZqL2e4vMjhAxoW3jVHcD6mbcYw== - dependencies: - decode-uri-component "^0.2.0" - filter-obj "^1.1.0" - split-on-first "^1.0.0" - strict-uri-encode "^2.0.0" - queue-microtask@^1.2.2: version "1.2.3" resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" @@ -4610,11 +4590,6 @@ source-map@^0.5.7: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" integrity sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ== -split-on-first@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/split-on-first/-/split-on-first-1.1.0.tgz#f610afeee3b12bce1d0c30425e76398b78249a5f" - integrity sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw== - stacktrace-parser@^0.1.10: version "0.1.10" resolved "https://registry.yarnpkg.com/stacktrace-parser/-/stacktrace-parser-0.1.10.tgz#29fb0cae4e0d0b85155879402857a1639eb6051a" @@ -4627,11 +4602,6 @@ statuses@2.0.1: resolved "https://registry.yarnpkg.com/statuses/-/statuses-2.0.1.tgz#55cb000ccf1d48728bd23c685a063998cf1a1b63" integrity sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ== -strict-uri-encode@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz#b9c7330c7042862f6b142dc274bbcc5866ce3546" - integrity sha512-QwiXZgpRcKkhTj2Scnn++4PKtWsH0kpzZ62L2R6c/LUVYv7hVnZqcg2+sMuT6R7Jusu1vviK/MFsu6kNJfWlEQ== - string.prototype.matchall@^4.0.10: version "4.0.11" resolved "https://registry.yarnpkg.com/string.prototype.matchall/-/string.prototype.matchall-4.0.11.tgz#1092a72c59268d2abaad76582dccc687c0297e0a"