( url: string, params: Record<string, string | number | boolean> | undefined )
| 1 | export function urlWithSearchParams( |
| 2 | url: string, |
| 3 | params: Record<string, string | number | boolean> | undefined |
| 4 | ) { |
| 5 | if (!params) { |
| 6 | return url; |
| 7 | } |
| 8 | |
| 9 | const urlObj = new URL(url); |
| 10 | for (const [key, value] of Object.entries(params)) { |
| 11 | if (value !== undefined) { |
| 12 | urlObj.searchParams.append(key, String(value)); |
| 13 | } |
| 14 | } |
| 15 | return urlObj.toString(); |
| 16 | } |
no test coverage detected
searching dependent graphs…