From 38cff7e6fc5825c1e59fcc846c41b10daf8bf70c Mon Sep 17 00:00:00 2001 From: Vedant Kulkarni Date: Thu, 5 Mar 2026 22:27:36 +0530 Subject: [PATCH] net: add note to docs about ipv4 mapped to ipv6 being classified as ipv6 --- doc/api/net.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/doc/api/net.md b/doc/api/net.md index f8cd3ccf8d3c40..aef61b3397672a 100644 --- a/doc/api/net.md +++ b/doc/api/net.md @@ -1976,12 +1976,13 @@ added: v0.3.0 * `input` {string} * Returns: {integer} -Returns `6` if `input` is an IPv6 address. Returns `4` if `input` is an IPv4 -address in [dot-decimal notation][] with no leading zeroes. Otherwise, returns -`0`. +Returns `6` if `input` is an IPv6 address or an IPv4 address mapped to IPv6. +Returns `4` if `input` is an IPv4 address in [dot-decimal notation][] with no +leading zeroes. Otherwise, returns `0`. ```js net.isIP('::1'); // returns 6 +net.isIP('::ffff:127.0.0.1'); // returns 6 net.isIP('127.0.0.1'); // returns 4 net.isIP('127.000.000.001'); // returns 0 net.isIP('127.0.0.1/24'); // returns 0 @@ -2016,10 +2017,12 @@ added: v0.3.0 * `input` {string} * Returns: {boolean} -Returns `true` if `input` is an IPv6 address. Otherwise, returns `false`. +Returns `true` if `input` is an IPv6 address or an IPv4 address mapped to IPv6. +Otherwise, returns `false`. ```js net.isIPv6('::1'); // returns true +net.isIPv6('::ffff:127.0.0.1'); // returns true net.isIPv6('fhqwhgads'); // returns false ```