Skip to content

Commit

Permalink
refactor: use substring (#2411)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsctx committed Nov 8, 2023
1 parent 57fd343 commit b8483ab
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/core/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b8483ab

Please sign in to comment.