From f8513f7311a689b90bddd5be50286bdd680a49dc Mon Sep 17 00:00:00 2001 From: Matthias Camenzind Date: Wed, 19 Jun 2024 19:39:31 +0200 Subject: [PATCH] Fix getQueryString Browsers without size property for URLSearchParams always returned an empty string. --- 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 ""; }