From b1604e9c9f80701a5cfd5a9a7f0f677b9510d37a Mon Sep 17 00:00:00 2001 From: matc-pub <161147791+matc-pub@users.noreply.github.com> Date: Wed, 19 Jun 2024 21:37:04 +0200 Subject: [PATCH] Fix getQueryString (#2558) Browsers without size property for URLSearchParams always returned an empty string. Co-authored-by: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com> --- src/shared/utils/helpers/get-query-string.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/shared/utils/helpers/get-query-string.ts b/src/shared/utils/helpers/get-query-string.ts index 6b9b6992..679663b7 100644 --- a/src/shared/utils/helpers/get-query-string.ts +++ b/src/shared/utils/helpers/get-query-string.ts @@ -5,8 +5,9 @@ export default function getQueryString< Object.entries(obj) .filter(([, val]) => val !== undefined && val !== null) .forEach(([key, val]) => searchParams.set(key, val ?? "")); - if (searchParams.size) { - return "?" + searchParams.toString(); + const params = searchParams.toString(); + if (params) { + return "?" + params; } return ""; }