Skip to content

Commit

Permalink
Fix getQueryString (#2558)
Browse files Browse the repository at this point in the history
Browsers without size property for URLSearchParams always returned an
empty string.

Co-authored-by: SleeplessOne1917 <[email protected]>
  • Loading branch information
matc-pub and SleeplessOne1917 authored Jun 19, 2024
1 parent 3bcb12e commit b1604e9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/shared/utils/helpers/get-query-string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 "";
}

0 comments on commit b1604e9

Please sign in to comment.