parse-listen-string
v2.1.3
Published
Parse a HTTP server listen string
Downloads
48
Readme
parse-listen-string
Node.js module to parse a listen string like 0.0.0.0:443
.
Install
npm i parse-listen-string
Usage
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"}
API
parseListenString(listenString)
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 addressport
Number: Listen portpath
String: Unix socket path, this is mutual exclusive withhost
andport
© silverwind, distributed under BSD licence