Skip to content

Commit 7563aff

Browse files
committed
net: optimize ipv6 check
1 parent 4e62937 commit 7563aff

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lib/internal/socketaddress.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ class SocketAddress {
158158
// the raw input string instead.
159159
const { hostname: address } = URLParse(`http://${input}`);
160160

161-
const isIPv6 = address.startsWith('[') && address.endsWith(']');
161+
const isIPv6 = address[0] === '[' && address.endsWith(']');
162162

163163
// For IPv6, indexOf(']:') + 1 points at ':' (or 0 if absent, treated as no port).
164164
// For IPv4, lastIndexOf(':') points at ':' (or -1 if absent).

0 commit comments

Comments
 (0)