Parse ip and port from a string that formed by "ip:port"
const parseIpPort = require('parse-ip-port');
try {
const [ip, port] = parseIpPort('127.0.0.1:80');
} catch (e) {
console.log(e.toString());
}
Parse ip/hostname and port from a string that formed by "ip:port"
JavaScript