(host: string)
| 68 | } |
| 69 | |
| 70 | function formatHostForUrl(host: string): string { |
| 71 | const trimmed = host.trim(); |
| 72 | |
| 73 | // IPv6 URLs must be bracketed: http://[::1]:1234 |
| 74 | if (trimmed.includes(":")) { |
| 75 | if (trimmed.startsWith("[") && trimmed.endsWith("]")) { |
| 76 | return trimmed; |
| 77 | } |
| 78 | |
| 79 | return `[${trimmed}]`; |
| 80 | } |
| 81 | |
| 82 | return trimmed; |
| 83 | } |
| 84 | |
| 85 | function buildHttpBaseUrl(host: string, port: number): string { |
| 86 | return `http://${formatHostForUrl(host)}:${port}`; |