2.0.0 • Published 2 years ago

split-host v2.0.0

Weekly downloads
22
License
ISC
Repository
github
Last release
2 years ago

split-host

Package Version License PackagePhobia Node compatibility

Split host into hostname and port

Install

Installation of the npm package:

> npm install --save split-host

Usage

import splitHost from "split-host";

splitHost("localhost:80");
// → { host: 'localhost', hostname: 'localhost', port: '80' }

splitHost("localhost");
// → { host: 'localhost', hostname: 'localhost' }

splitHost("80");
// → { port: 80 }

// IPv6 addresses must be enclosed in []

splitHost("[::1]:80");
// → { host: '::1', hostname: '::1', port: '80' }

splitHost("[::1]");
// → { host: '::1', hostname: '::1' }

host is provided as an alias for hostname because a lot of Node's APIs expect such an entry.

Contributions

Contributions are very welcomed, either on the documentation or on the code.

You may:

  • report any issue you've encountered;
  • fork and create a pull request.

License

ISC © Julien Fontanet

2.0.0

2 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.0

7 years ago