mirror of
https://github.com/aljazceru/mutiny-web.git
synced 2025-12-27 10:54:21 +01:00
7 lines
391 B
TypeScript
7 lines
391 B
TypeScript
export function objectToSearchParams<T extends Record<string, string | undefined>>(obj: T): string {
|
|
return Object.entries(obj)
|
|
.filter(([_, value]) => value !== undefined)
|
|
// Value shouldn't be null we just filtered it out but typescript is dumb
|
|
.map(([key, value]) => value ? `${encodeURIComponent(key)}=${encodeURIComponent(value)}` : "")
|
|
.join("&");
|
|
} |