( baseUrl: string, path: string, query?: Record<string, string | number | boolean | undefined>, )
| 662 | } |
| 663 | |
| 664 | export function buildUrl( |
| 665 | baseUrl: string, |
| 666 | path: string, |
| 667 | query?: Record<string, string | number | boolean | undefined>, |
| 668 | ): string { |
| 669 | const normalizedPath = path.startsWith('/') ? path : `/${path}`; |
| 670 | const url = new URL(`${trimTrailingSlash(baseUrl)}${normalizedPath}`); |
| 671 | if (query) { |
| 672 | for (const [key, value] of Object.entries(query)) { |
| 673 | if (value === undefined) continue; |
| 674 | url.searchParams.set(key, String(value)); |
| 675 | } |
| 676 | } |
| 677 | return url.toString(); |
| 678 | } |
| 679 | |
| 680 | function newRequestId(): string { |
| 681 | return `cli_${randomUUID()}`; |
no test coverage detected