Skip to content

Commit 38cff7e

Browse files
committed
net: add note to docs about ipv4 mapped to ipv6 being classified as ipv6
1 parent 4431abc commit 38cff7e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

doc/api/net.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,12 +1976,13 @@ added: v0.3.0
19761976
* `input` {string}
19771977
* Returns: {integer}
19781978

1979-
Returns `6` if `input` is an IPv6 address. Returns `4` if `input` is an IPv4
1980-
address in [dot-decimal notation][] with no leading zeroes. Otherwise, returns
1981-
`0`.
1979+
Returns `6` if `input` is an IPv6 address or an IPv4 address mapped to IPv6.
1980+
Returns `4` if `input` is an IPv4 address in [dot-decimal notation][] with no
1981+
leading zeroes. Otherwise, returns `0`.
19821982

19831983
```js
19841984
net.isIP('::1'); // returns 6
1985+
net.isIP('::ffff:127.0.0.1'); // returns 6
19851986
net.isIP('127.0.0.1'); // returns 4
19861987
net.isIP('127.000.000.001'); // returns 0
19871988
net.isIP('127.0.0.1/24'); // returns 0
@@ -2016,10 +2017,12 @@ added: v0.3.0
20162017
* `input` {string}
20172018
* Returns: {boolean}
20182019

2019-
Returns `true` if `input` is an IPv6 address. Otherwise, returns `false`.
2020+
Returns `true` if `input` is an IPv6 address or an IPv4 address mapped to IPv6.
2021+
Otherwise, returns `false`.
20202022

20212023
```js
20222024
net.isIPv6('::1'); // returns true
2025+
net.isIPv6('::ffff:127.0.0.1'); // returns true
20232026
net.isIPv6('fhqwhgads'); // returns false
20242027
```
20252028

0 commit comments

Comments
 (0)