Fix getQueryString (#2558)

Browsers without size property for URLSearchParams always returned an
empty string.

Co-authored-by: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com>
This commit is contained in:
matc-pub 2024-06-19 21:37:04 +02:00 committed by GitHub
parent 3bcb12eff9
commit b1604e9c9f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

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