Skip to content

Commit 46541f9

Browse files
authored
doc: clarify that ipv4 mapped to ipv6 are classified as ipv6
Signed-off-by: Vedant Kulkarni <gamemaker0042@gmail.com> PR-URL: #62117 Reviewed-By: Ethan Arrowood <ethan@arrowood.dev> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent f3a8f1a commit 46541f9

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

doc/api/net.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2443,12 +2443,13 @@ added: v0.3.0
24432443
* `input` {string}
24442444
* Returns: {integer}
24452445

2446-
Returns `6` if `input` is an IPv6 address. Returns `4` if `input` is an IPv4
2447-
address in [dot-decimal notation][] with no leading zeroes. Otherwise, returns
2448-
`0`.
2446+
Returns `6` if `input` is an IPv6 address, including an IPv4-mapped IPv6 address.
2447+
Returns `4` if `input` is an IPv4 address in [dot-decimal notation][] with no
2448+
leading zeroes. Otherwise, returns `0`.
24492449

24502450
```js
24512451
net.isIP('::1'); // returns 6
2452+
net.isIP('::ffff:127.0.0.1'); // returns 6
24522453
net.isIP('127.0.0.1'); // returns 4
24532454
net.isIP('127.000.000.001'); // returns 0
24542455
net.isIP('127.0.0.1/24'); // returns 0
@@ -2483,10 +2484,12 @@ added: v0.3.0
24832484
* `input` {string}
24842485
* Returns: {boolean}
24852486

2486-
Returns `true` if `input` is an IPv6 address. Otherwise, returns `false`.
2487+
Returns `true` if `input` is an IPv6 address, including an IPv4-mapped IPv6 address.
2488+
Otherwise, returns `false`.
24872489

24882490
```js
24892491
net.isIPv6('::1'); // returns true
2492+
net.isIPv6('::ffff:127.0.0.1'); // returns true
24902493
net.isIPv6('fhqwhgads'); // returns false
24912494
```
24922495

0 commit comments

Comments
 (0)