(host: string)
| 50 | ]) |
| 51 | |
| 52 | function isPrivateIPv4(host: string): boolean { |
| 53 | const match = host.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/) |
| 54 | if (!match) return false |
| 55 | const octets = match.slice(1, 5).map(Number) as [number, number, number, number] |
| 56 | if (octets.some((octet) => octet < 0 || octet > 255)) return false |
| 57 | const [a, b] = octets |
| 58 | if (a === 10) return true |
| 59 | if (a === 172 && b >= 16 && b <= 31) return true |
| 60 | if (a === 192 && b === 168) return true |
| 61 | if (a === 127) return true |
| 62 | if (a === 169 && b === 254) return true |
| 63 | if (a === 0) return true |
| 64 | return false |
| 65 | } |
| 66 | |
| 67 | function extractIPv4MappedHost(host: string): string | null { |
| 68 | const stripped = host.startsWith('[') && host.endsWith(']') ? host.slice(1, -1) : host |
no outgoing calls
no test coverage detected