Node.js module to parse a listen string like 0.0.0.0:443
.
npm i parse-listen-string
import {parseListenString} from "parse-listen-string";
parseListenString("0.0.0.0:80")
//=> {host: "0.0.0.0", port: 80, proto: "http"}
parseListenString("https://[::1]:443")
//=> {host: "::1", port: 443, proto: "https"}
-
listenString
String or Number: A listen string to parse
Returns a object or null
if string can not be parsed. Object properties:
-
proto
String. Protocol, eitherhttp
orhttps
-
host
String: Listen host in form of an IP address -
port
Number: Listen port -
path
String: Unix socket path, this is mutual exclusive withhost
andport
© silverwind, distributed under BSD licence