Skip to content

Commit 102d4cf

Browse files
committed
net: recognize bare IPv6 loopback addresses in isLoopback
Signed-off-by: Daijiro Wachi <daijiro.wachi@gmail.com>
1 parent 2cd9d2c commit 102d4cf

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

lib/internal/net.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ function isLoopback(host) {
9494
hostLower === 'localhost' ||
9595
hostLower.startsWith('127.') ||
9696
hostLower === '[::1]' ||
97-
hostLower === '[0:0:0:0:0:0:0:1]'
97+
hostLower === '::1' ||
98+
hostLower === '[0:0:0:0:0:0:0:1]' ||
99+
hostLower === '0:0:0:0:0:0:0:1'
98100
);
99101
}
100102

test/parallel/test-internal-net-isLoopback.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ const loopback = [
1010
'127.0.0.255',
1111
'127.1.2.3',
1212
'[::1]',
13+
'::1',
1314
'[0:0:0:0:0:0:0:1]',
15+
'0:0:0:0:0:0:0:1',
1416
];
1517

1618
const loopbackNot = [

0 commit comments

Comments
 (0)