(host: string)
| 109 | ]) |
| 110 | |
| 111 | function isPrivateIPv4(host: string): boolean { |
| 112 | const match = host.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/) |
| 113 | if (!match) return false |
| 114 | const octets = match.slice(1, 5).map(Number) as [number, number, number, number] |
| 115 | if (octets.some((o) => o < 0 || o > 255)) return false |
| 116 | const [a, b] = octets |
| 117 | if (a === 10) return true |
| 118 | if (a === 172 && b >= 16 && b <= 31) return true |
| 119 | if (a === 192 && b === 168) return true |
| 120 | if (a === 127) return true |
| 121 | if (a === 169 && b === 254) return true |
| 122 | if (a === 0) return true |
| 123 | return false |
| 124 | } |
| 125 | |
| 126 | function isPrivateOrLoopbackIPv6(host: string): boolean { |
| 127 | const stripped = host.startsWith('[') && host.endsWith(']') ? host.slice(1, -1) : host |
no outgoing calls
no test coverage detected