(hostname: string)
| 41 | // these forms, so the URL path never produces one, but a resolver answer |
| 42 | // reaches isAllowedResolvedAddress unnormalized. |
| 43 | const parseIpv4 = (hostname: string): readonly [number, number, number, number] | null => { |
| 44 | const parts = hostname.split("."); |
| 45 | if (parts.length !== 4) return null; |
| 46 | const parsed: number[] = []; |
| 47 | for (const part of parts) { |
| 48 | if (!/^(?:0|[1-9]\d*)$/.test(part)) return null; |
| 49 | const value = Number(part); |
| 50 | if (!Number.isInteger(value) || value < 0 || value > 255) return null; |
| 51 | parsed.push(value); |
| 52 | } |
| 53 | return parsed as [number, number, number, number]; |
| 54 | }; |
| 55 | |
| 56 | // `allowTrailingQuad` is the caller's statement that this segment ends the |
| 57 | // whole address, not merely that it ends its own half. Deciding it from the |
no test coverage detected