diff --git a/lib/internal/socketaddress.js b/lib/internal/socketaddress.js index 724ffd90cf77f1..28696d6cc87f6e 100644 --- a/lib/internal/socketaddress.js +++ b/lib/internal/socketaddress.js @@ -157,7 +157,7 @@ class SocketAddress { hostname: address, port, } = URLParse(`http://${input}`); - if (address.startsWith('[') && address.endsWith(']')) { + if (address[0] === '[' && address[address.length - 1] === ']') { return new SocketAddress({ address: address.slice(1, -1), port: port | 0,