(host: string)
| 30 | } |
| 31 | |
| 32 | export function isLoopbackHost(host: string): boolean { |
| 33 | const normalized = host.trim().toLowerCase().replaceAll('[', '').replaceAll(']', ''); |
| 34 | return ( |
| 35 | normalized === 'localhost' || |
| 36 | normalized === '::1' || |
| 37 | normalized === '0:0:0:0:0:0:0:1' || |
| 38 | normalized.startsWith('127.') |
| 39 | ); |
| 40 | } |
| 41 | |
| 42 | /** Format a host for embedding in a URL authority. Bare IPv6 literals (which |
| 43 | * contain ':') must be bracketed, e.g. `::1` → `[::1]`, otherwise |
no outgoing calls
no test coverage detected