Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const formatDestAddress = (ip: string) => {
const hasPort = !isNaN(ip.split(':').pop() || ('' as any))
if (isIp.v4(ip) && hasPort) {
return ip
}
return urlFormat({ hostname: ip, port: WEBSOCKET_PORT_DEFAULT })
}
function isIP (string) {
if (isIpLib.v4(string)) return 4
else if (isIpLib.v6(string)) return 6
else return 0
}