diff --git a/lib/client.js b/lib/client.js index 968a7f92071..056cc97a35f 100644 --- a/lib/client.js +++ b/lib/client.js @@ -1183,7 +1183,7 @@ async function connect (client) { const idx = hostname.indexOf(']') assert(idx !== -1) - const ip = hostname.substr(1, idx - 1) + const ip = hostname.substring(1, idx) assert(net.isIP(ip)) hostname = ip diff --git a/lib/core/util.js b/lib/core/util.js index 7fe2229c3c4..52c6b985883 100644 --- a/lib/core/util.js +++ b/lib/core/util.js @@ -125,13 +125,13 @@ function getHostname (host) { const idx = host.indexOf(']') assert(idx !== -1) - return host.substr(1, idx - 1) + return host.substring(1, idx) } const idx = host.indexOf(':') if (idx === -1) return host - return host.substr(0, idx) + return host.substring(0, idx) } // IP addresses are not valid server names per RFC6066