Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ jobs:
release:
name: Release ${{ github.ref }}
needs: test
# if: github.ref == 'refs/heads/main' && github.event_name == 'push'
if: github.event_name == 'turned-off-temporary'
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
# if: github.event_name == 'turned-off-temporary'
runs-on: ubuntu-latest
permissions:
checks: read
Expand Down
10 changes: 5 additions & 5 deletions .size-limit.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"LICENSE",
"package-main.json"
],
"limit": "60.00 kB",
"limit": "60.20 kB",
"brotli": false,
"gzip": false
},
Expand All @@ -18,7 +18,7 @@
"path": [
"target/*/core.*"
],
"limit": "41 kB",
"limit": "41.15 kB",
"brotli": false,
"gzip": false
},
Expand All @@ -32,15 +32,15 @@
"LICENSE",
"package-main.json"
],
"limit": "18.10 kB",
"limit": "18.25 kB",
"gzip": true
},
{
"name": "cjs",
"path": [
"target/cjs"
],
"limit": "25.30 kB",
"limit": "25.40 kB",
"brotli": false,
"gzip": false
},
Expand All @@ -49,7 +49,7 @@
"path": [
"target/esm"
],
"limit": "20.95 kB",
"limit": "21.00 kB",
"brotli": false,
"gzip": false
},
Expand Down
40 changes: 40 additions & 0 deletions BENCHMARK.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Performance across libraries
> Autogenerated by `src/scripts/build-bench-md.ts`

**System Info**
- Apple M3 Max (16 cores), 64.0 GB
- Darwin 24.6.0 (darwin arm64)
- Node.js v24.2.0

## IPv4
| # | Name | Ops/sec | Avg time (ms) | ± % |
| --- | --- | ---: | ---: | ---: |
| 1 | node:net | 4961035.41 | 0.000 | ±246.97% |
| 2 | neoip | 3955073.30 | 0.000 | ±224.27% |
| 3 | @webpod/ip | 3849196.73 | 0.000 | ±65.91% |
| 4 | ip | 3313577.42 | 0.000 | ±222.50% |
| 5 | @webpod/ip/core | 3000048.99 | 0.000 | ±25.16% |
| 6 | ip2buf | 44536.30 | 0.022 | ±32.62% |
| 7 | ip-address | 38409.27 | 0.026 | ±71.59% |
| 8 | ipaddr.js | 15623.47 | 0.064 | ±35.40% |
| 9 | is-ip | 353.18 | 2.831 | ±32.13% |
## IPv6
| # | Name | Ops/sec | Avg time (ms) | ± % |
| --- | --- | ---: | ---: | ---: |
| 1 | node:net | 412949.28 | 0.002 | ±71.44% |
| 2 | @webpod/ip | 411210.66 | 0.002 | ±18.33% |
| 3 | neoip | 397130.19 | 0.003 | ±109.62% |
| 4 | ip2buf | 19833.55 | 0.050 | ±30.69% |
| 5 | @webpod/ip/core | 15951.71 | 0.063 | ±29.00% |
| 6 | ip-address | 11943.45 | 0.084 | ±99.54% |
| 7 | ip | 7108.96 | 0.141 | ±9.46% |
| 8 | ipaddr.js | 4001.49 | 0.250 | ±16.61% |
| 9 | is-ip | 209.12 | 4.782 | ±4.01% |
## Private IP
| # | Name | Ops/sec | Avg time (ms) | ± % |
| --- | --- | ---: | ---: | ---: |
| 1 | ip | 105002.56 | 0.010 | ±109.63% |
| 2 | @webpod/ip/core | 29683.28 | 0.034 | ±38.01% |
| 3 | @webpod/ip | 29531.26 | 0.034 | ±35.77% |
| 4 | ipaddr.js | 18058.26 | 0.055 | ±41.60% |
| 5 | neoip | 15729.85 | 0.064 | ±53.98% |
166 changes: 83 additions & 83 deletions COHERENCE.md
Original file line number Diff line number Diff line change
@@ -1,88 +1,88 @@
# Coherence across libraries
> Autogenerated by `src/scripts/build-coherence-md.ts`
## IPv4
Address | node:net | [`ip`](https://github.com/indutny/node-ip) | [`@webpod/ip`](https://github.com/webpod/ip) | [`is-ip`](https://github.com/sindresorhus/is-ip) | [`ipaddr.js`](https://github.com/whitequark/ipaddr.js/) | [`ip-address`](https://github.com/beaugunderson/ip-address) | [`ip2buf`](https://github.com/reklatsmasters/ip2buf) | [`neoip`](https://github.com/Zaptic/neoip) | Comment
--- | --- | --- | --- | --- | --- | --- | --- | --- | ---
`127.0.0.1` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | localhost
`192.168.1.1` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | private LAN
`255.255.255.255` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | broadcast
`0.0.0.0` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | unspecified
`8.8.8.8` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | Google DNS
`256.1.1.1` | ✓ | ❌ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | octet out of range
`192.168.1` | ✓ | ✓ | ✓ | ✓ | ❌ | ✓ | ✓ | ✓ | not enough octets
`192.168.1.1.1` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | too many octets
`192.168.01.1` | ✓ | ❌ | ✓ | ✓ | ❌ | ❌ | ❌ | ✓ | leading octet zero
`abc.def.gha.bcd` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | non-numeric
`...` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | empty octets
`1..2.3` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | empty middle octet
`` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | empty string
Address | node:net | [`ip`](https://github.com/indutny/node-ip) | [`@webpod/ip`](https://github.com/webpod/ip) | [`@webpod/ip/core`](https://github.com/webpod/ip) | [`is-ip`](https://github.com/sindresorhus/is-ip) | [`ipaddr.js`](https://github.com/whitequark/ipaddr.js/) | [`ip-address`](https://github.com/beaugunderson/ip-address) | [`ip2buf`](https://github.com/reklatsmasters/ip2buf) | [`neoip`](https://github.com/Zaptic/neoip) | Comment
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ---
`127.0.0.1` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | localhost
`192.168.1.1` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | private LAN
`255.255.255.255` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | broadcast
`0.0.0.0` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | unspecified
`8.8.8.8` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | Google DNS
`256.1.1.1` | ✓ | ❌ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | octet out of range
`192.168.1` | ✓ | ✓ | ✓ | ✓ | ✓ | ❌ | ✓ | ✓ | ✓ | not enough octets
`192.168.1.1.1` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | too many octets
`192.168.01.1` | ✓ | ❌ | ✓ | ✓ | ✓ | ❌ | ❌ | ❌ | ✓ | leading octet zero
`abc.def.gha.bcd` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | non-numeric
`...` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | empty octets
`1..2.3` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | empty middle octet
`` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | empty string
## IPv6
Address | node:net | [`ip`](https://github.com/indutny/node-ip) | [`@webpod/ip`](https://github.com/webpod/ip) | [`is-ip`](https://github.com/sindresorhus/is-ip) | [`ipaddr.js`](https://github.com/whitequark/ipaddr.js/) | [`ip-address`](https://github.com/beaugunderson/ip-address) | [`ip2buf`](https://github.com/reklatsmasters/ip2buf) | [`neoip`](https://github.com/Zaptic/neoip) | Comment
--- | --- | --- | --- | --- | --- | --- | --- | --- | ---
`::1` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | loopback
`::` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | unspecified
`2001:db8::1` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | documentation address
`fe80::1ff:fe23:4567:890a` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | link-local
`::ffff:192.0.2.128` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | IPv4-mapped IPv6
`2001:0db8:85a3:0000:0000:8a2e:0370:7334` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | full form
`0:0:0:0:0:0:0:1` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | expanded loopback
`2001::85a3::7334` | ✓ | ❌ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | multiple ::
`12345::` | ✓ | ❌ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | hextet too long
`abcd:efgh::1` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | non-hex character
`1:2:3:4:5:6:7` | ✓ | ❌ | ✓ | ✓ | ✓ | ✓ | ❌ | ✓ | too few hextets
`1:2:3:4:5:6:7:8:9` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | too many hextets
`:1:2:3:4:5:6:7` | ✓ | ❌ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | leading colon without ::
`1:2:3:4:5:6:7:` | ✓ | ❌ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | trailing colon without ::
`1:2:3::4:5:6:7:8` | ✓ | ❌ | ✓ | ✓ | ❌ | ✓ | ✓ | ✓ | too many hextets with ::
`1:2::4:5::8` | ✓ | ❌ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | multiple compressors ::
`:::` | ✓ | ❌ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | triple colon not allowed
`::g` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | invalid hex digit after compression
`2001:db8:85a3:0:0:8a2e:37023:7334` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | hextet exceeds 16 bits
`::ffff:999.0.2.128` | ✓ | ❌ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | invalid embedded IPv4
`::ffff:192.0.2` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | truncated IPv4 in mapped address
`2001:db8:::` | ✓ | ❌ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | extra colon at end
`` | ✓ | ❌ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | empty string
Address | node:net | [`ip`](https://github.com/indutny/node-ip) | [`@webpod/ip`](https://github.com/webpod/ip) | [`@webpod/ip/core`](https://github.com/webpod/ip) | [`is-ip`](https://github.com/sindresorhus/is-ip) | [`ipaddr.js`](https://github.com/whitequark/ipaddr.js/) | [`ip-address`](https://github.com/beaugunderson/ip-address) | [`ip2buf`](https://github.com/reklatsmasters/ip2buf) | [`neoip`](https://github.com/Zaptic/neoip) | Comment
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ---
`::1` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | loopback
`::` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | unspecified
`2001:db8::1` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | documentation address
`fe80::1ff:fe23:4567:890a` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | link-local
`::ffff:192.0.2.128` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | IPv4-mapped IPv6
`2001:0db8:85a3:0000:0000:8a2e:0370:7334` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | full form
`0:0:0:0:0:0:0:1` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | expanded loopback
`2001::85a3::7334` | ✓ | ❌ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | multiple ::
`12345::` | ✓ | ❌ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | hextet too long
`abcd:efgh::1` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | non-hex character
`1:2:3:4:5:6:7` | ✓ | ❌ | ✓ | ✓ | ✓ | ✓ | ✓ | ❌ | ✓ | too few hextets
`1:2:3:4:5:6:7:8:9` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | too many hextets
`:1:2:3:4:5:6:7` | ✓ | ❌ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | leading colon without ::
`1:2:3:4:5:6:7:` | ✓ | ❌ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | trailing colon without ::
`1:2:3::4:5:6:7:8` | ✓ | ❌ | ✓ | ✓ | ✓ | ❌ | ✓ | ✓ | ✓ | too many hextets with ::
`1:2::4:5::8` | ✓ | ❌ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | multiple compressors ::
`:::` | ✓ | ❌ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | triple colon not allowed
`::g` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | invalid hex digit after compression
`2001:db8:85a3:0:0:8a2e:37023:7334` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | hextet exceeds 16 bits
`::ffff:999.0.2.128` | ✓ | ❌ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | invalid embedded IPv4
`::ffff:192.0.2` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | truncated IPv4 in mapped address
`2001:db8:::` | ✓ | ❌ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | extra colon at end
`` | ✓ | ❌ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | empty string
## Private IP
Address | [`ip`](https://github.com/indutny/node-ip) | [`@webpod/ip`](https://github.com/webpod/ip) | [`ipaddr.js`](https://github.com/whitequark/ipaddr.js/) | [`neoip`](https://github.com/Zaptic/neoip) | Comment
--- | --- | --- | --- | --- | ---
`0.0.0.0` | ❌ | ✓ | ✓ | ✓ | unspecified
`127.0.0.1` | ✓ | ✓ | ✓ | ✓ | loopback
`127.0.0.2` | ✓ | ✓ | ✓ | ✓ | loopback range
`127.1.1.1` | ✓ | ✓ | ✓ | ✓ | loopback shorthand
`192.168.0.123` | ✓ | ✓ | ✓ | ✓ | private LAN
`192.168.122.123` | ✓ | ✓ | ✓ | ✓ | private LAN
`192.162.1.2` | ✓ | ✓ | ✓ | ✓ | public, outside 192.168/16
`172.16.0.5` | ✓ | ✓ | ✓ | ✓ | private start
`172.16.123.254` | ✓ | ✓ | ✓ | ✓ | private inside
`171.16.0.5` | ✓ | ✓ | ✓ | ✓ | public, below range
`172.25.232.15` | ✓ | ✓ | ✓ | ✓ | private inside
`172.15.0.5` | ✓ | ✓ | ✓ | ✓ | public, below range
`172.32.0.5` | ✓ | ✓ | ✓ | ✓ | public, above range
`169.254.2.3` | ✓ | ✓ | ✓ | ✓ | link-local
`169.254.221.9` | ✓ | ✓ | ✓ | ✓ | link-local
`168.254.2.3` | ✓ | ✓ | ✓ | ✓ | public, outside 169.254/16
`10.0.2.3` | ✓ | ✓ | ✓ | ✓ | private 10/8
`10.1.23.45` | ✓ | ✓ | ✓ | ✓ | private 10/8
`12.1.2.3` | ✓ | ✓ | ✓ | ✓ | public, outside 10/8
`198.18.0.0` | ❌ | ✓ | ❌ | ✓ | benchmark range
`fd12:3456:789a:1::1` | ✓ | ✓ | ✓ | ✓ | ULA fc00::/7
`fe80::f2de:f1ff:fe3f:307e` | ✓ | ✓ | ✓ | ✓ | link-local fe80::/10
`::ffff:10.100.1.42` | ✓ | ✓ | ❌ | ✓ | IPv4-mapped private
`::FFFF:172.16.200.1` | ✓ | ✓ | ❌ | ✓ | IPv4-mapped private
`::ffff:192.168.0.1` | ✓ | ✓ | ❌ | ✓ | IPv4-mapped private
`165.225.132.33` | ✓ | ✓ | ✓ | ✓ | public
`::` | ✓ | ✓ | ✓ | ✓ | unspecified
`::1` | ✓ | ✓ | ✓ | ✓ | loopback
`fe80::1` | ✓ | ✓ | ✓ | ✓ | link-local
`0x7f.1` | ✓ | ✓ | ✓ | ✓ | CVE-2023-42282: hex loopback
`127.1` | ❌ | ✓ | ✓ | ✓ | CVE-2024-29415: short loopback
`2130706433` | ✓ | ✓ | ✓ | ✓ | CVE-2024-29415: integer loopback
`::fFFf:127.0.0.1` | ❌ | ✓ | ❌ | ✓ | CVE-2024-29415: IPv6-mapped loopback
`::0:ffff:127.0.0.1` | ❌ | ✓ | ❌ | ✓ | ↑
`0::0:ffff:127.0.0.1` | ❌ | ✓ | ❌ | ✓ | ↑
`0:0:0:0:0:ffff:127.0.0.1` | ❌ | ✓ | ❌ | ✓ | ↑
`01200034567` | ✓ | n/a | | ❌ | invalid: octal-style
`012.1.2.3` | ✓ | n/a | ❌ | ❌ | invalid: octal-style IPv4
`000:0:0000::01` | | | | | valid: zero-compression
`::fFFf:127.255.255.256` | ✓ | n/a | n/a | ✓ | invalid: IPv4 overflow
`017700000001` | ✓ | n/a | | | octal 127.0.0.1
Address | [`ip`](https://github.com/indutny/node-ip) | [`@webpod/ip`](https://github.com/webpod/ip) | [`@webpod/ip/core`](https://github.com/webpod/ip) | [`ipaddr.js`](https://github.com/whitequark/ipaddr.js/) | [`neoip`](https://github.com/Zaptic/neoip) | Comment
--- | --- | --- | --- | --- | --- | ---
`0.0.0.0` | ❌ | ✓ | ✓ | ✓ | ✓ | unspecified
`127.0.0.1` | ✓ | ✓ | ✓ | ✓ | ✓ | loopback
`127.0.0.2` | ✓ | ✓ | ✓ | ✓ | ✓ | loopback range
`127.1.1.1` | ✓ | ✓ | ✓ | ✓ | ✓ | loopback shorthand
`192.168.0.123` | ✓ | ✓ | ✓ | ✓ | ✓ | private LAN
`192.168.122.123` | ✓ | ✓ | ✓ | ✓ | ✓ | private LAN
`192.162.1.2` | ✓ | ✓ | ✓ | ✓ | ✓ | public, outside 192.168/16
`172.16.0.5` | ✓ | ✓ | ✓ | ✓ | ✓ | private start
`172.16.123.254` | ✓ | ✓ | ✓ | ✓ | ✓ | private inside
`171.16.0.5` | ✓ | ✓ | ✓ | ✓ | ✓ | public, below range
`172.25.232.15` | ✓ | ✓ | ✓ | ✓ | ✓ | private inside
`172.15.0.5` | ✓ | ✓ | ✓ | ✓ | ✓ | public, below range
`172.32.0.5` | ✓ | ✓ | ✓ | ✓ | ✓ | public, above range
`169.254.2.3` | ✓ | ✓ | ✓ | ✓ | ✓ | link-local
`169.254.221.9` | ✓ | ✓ | ✓ | ✓ | ✓ | link-local
`168.254.2.3` | ✓ | ✓ | ✓ | ✓ | ✓ | public, outside 169.254/16
`10.0.2.3` | ✓ | ✓ | ✓ | ✓ | ✓ | private 10/8
`10.1.23.45` | ✓ | ✓ | ✓ | ✓ | ✓ | private 10/8
`12.1.2.3` | ✓ | ✓ | ✓ | ✓ | ✓ | public, outside 10/8
`198.18.0.0` | ❌ | ✓ | ✓ | ❌ | ✓ | benchmark range
`fd12:3456:789a:1::1` | ✓ | ✓ | ✓ | ✓ | ✓ | ULA fc00::/7
`fe80::f2de:f1ff:fe3f:307e` | ✓ | ✓ | ✓ | ✓ | ✓ | link-local fe80::/10
`::ffff:10.100.1.42` | ✓ | ✓ | ✓ | ❌ | ✓ | IPv4-mapped private
`::FFFF:172.16.200.1` | ✓ | ✓ | ✓ | ❌ | ✓ | IPv4-mapped private
`::ffff:192.168.0.1` | ✓ | ✓ | ✓ | ❌ | ✓ | IPv4-mapped private
`165.225.132.33` | ✓ | ✓ | ✓ | ✓ | ✓ | public
`::` | ✓ | ✓ | ✓ | ✓ | ✓ | unspecified
`::1` | ✓ | ✓ | ✓ | ✓ | ✓ | loopback
`fe80::1` | ✓ | ✓ | ✓ | ✓ | ✓ | link-local
`0x7f.1` | ✓ | ✓ | ✓ | ✓ | ✓ | CVE-2023-42282: hex loopback
`127.1` | ❌ | ✓ | ✓ | ✓ | ✓ | CVE-2024-29415: short loopback
`2130706433` | ✓ | ✓ | ✓ | ✓ | ✓ | CVE-2024-29415: integer loopback
`::fFFf:127.0.0.1` | ❌ | ✓ | ✓ | ❌ | ✓ | CVE-2024-29415: IPv6-mapped loopback
`::0:ffff:127.0.0.1` | ❌ | ✓ | ✓ | ❌ | ✓ | ↑
`0::0:ffff:127.0.0.1` | ❌ | ✓ | ✓ | ❌ | ✓ | ↑
`0:0:0:0:0:ffff:127.0.0.1` | ❌ | ✓ | ✓ | ❌ | ✓ | ↑
`017700000001` | ✓ | n/a | n/a | ❌ | ❌ | octal 127.0.0.1
`01200034567` | ✓ | n/a | n/a | ❌ | ❌ | invalid: octal-style
`012.1.2.3` | | n/a | n/a | | ❌ | invalid: octal-style IPv4
`000:0:0000::01` | ❌ | ✓ | | | ✓ | valid: zero-compression
`::fFFf:127.255.255.256` | ✓ | n/a | n/a | n/a | ✓ | invalid: IPv4 overflow
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Address.isSpecial('1.2.3.4') // false
```

## Alternatives
Follow [coherence.md](./COHERENCE.md) to explore suitable options.
Follow [coherence.md](./COHERENCE.md) and [benchmark.md](./BENCHMARK.md) to explore suitable options.

## License
MIT
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"exports": {
".": {
"types": "./target/dts/index.d.ts",
"browser": "./target/esm/core.mjs",
"require": "./target/cjs/index.cjs",
"import": "./target/esm/index.mjs",
"default": "./target/esm/index.mjs"
Expand Down Expand Up @@ -39,6 +40,8 @@
"build:stamp": "npx buildstamp",
"build:jsr": "node ./src/scripts/build-jsr.mjs",
"build:pkgjson": "node ./src/scripts/build-pkgjson.ts",
"_build:bench": "node ./src/scripts/build-bench-md.ts",
"_build:coh": "node ./src/scripts/build-coherence-md.ts",
"test": "concurrently 'npm:test:*'",
"test:target": "git diff --exit-code --quiet || (echo 'Uncommitted changes' && exit 1)",
"test:size": "size-limit",
Expand Down
3 changes: 2 additions & 1 deletion src/main/ts/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const IPV4_LB = '127.0.0.1'
const IPV6_LB = 'fe80::1'
const IPV6_MAX = (1n << 128n) - 1n
const IPV4_MAX = 0xffffffffn
const IPV4_RE = /^(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}$/

const OCT_RE = /^0[0-7]+$/
const HEX_RE = /^[0-9a-fA-F]+$/
Expand Down Expand Up @@ -557,7 +558,7 @@ export function fromLong(n: number | bigint | `${bigint}`): string {
}

export const isV4Format: Checker = (addr: string): boolean=> {
return isIPv4Candidate(addr) && Address.normalizeToLong(addr, true) !== -1
return addr.length <= IPV4_LEN_LIM && IPV4_RE.test(addr)

Copilot AI Sep 28, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable IPV4_LEN_LIM is referenced but not defined in the visible context. This will cause a runtime error if the constant is not properly defined elsewhere in the file.

Copilot uses AI. Check for mistakes.
}

export const isV6Format: Checker = (addr: string): boolean => {
Expand Down
Loading
Loading