* Check whether an address string is a loopback address. * Node may normalize IPv4 loopback to an IPv6-mapped address. * * Extracted from codexOauthService.ts where validateLoopback is used.
(address: string | undefined)
| 76 | * Extracted from codexOauthService.ts where validateLoopback is used. |
| 77 | */ |
| 78 | function isLoopbackAddress(address: string | undefined): boolean { |
| 79 | if (!address) return false; |
| 80 | |
| 81 | // Node may normalize IPv4 loopback to an IPv6-mapped address. |
| 82 | if (address === "::ffff:127.0.0.1") { |
| 83 | return true; |
| 84 | } |
| 85 | |
| 86 | return address === "127.0.0.1" || address === "::1"; |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Format a `server.listen()` host value for use inside a URL. |
no outgoing calls
no test coverage detected