* Checks if an IP address is private or reserved (not routable on the public internet) * Uses ipaddr.js for robust handling of all IP formats including: * - Octal notation (0177.0.0.1) * - Hex notation (0x7f000001) * - IPv4-mapped IPv6 (::ffff:127.0.0.1) * - Various edge cases that regex patter
(ip: string)
| 806 | * - Various edge cases that regex patterns miss |
| 807 | */ |
| 808 | function isPrivateOrReservedIP(ip: string): boolean { |
| 809 | try { |
| 810 | if (!ipaddr.isValid(ip)) { |
| 811 | return true |
| 812 | } |
| 813 | |
| 814 | const addr = ipaddr.process(ip) |
| 815 | const range = addr.range() |
| 816 | |
| 817 | return range !== 'unicast' |
| 818 | } catch { |
| 819 | return true |
| 820 | } |
| 821 | } |
| 822 | |
| 823 | /** |
| 824 | * Validates an Airtable ID (base, table, or webhook ID) |
no outgoing calls
no test coverage detected