url-format-lax
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/url-format-lax package

2.0.0 • Public • Published

url-format-lax

Lax url.format() that formats a hostname and port into IPv6-compatible socket form of hostname:port

Install

$ npm install url-format-lax

Usage

import urlFormat from 'url-format-lax';

urlFormat({hostname: '::1', port: '123'});
//=> '[::1]:123'

urlFormat({protocol: 'https', hostname: 'google.com', port: '123'});
//=> 'google.com:123'

And with the builtin url.format():

import url from 'url';

url.format({hostname: '::1', port: '123'});
//=> '//[::1]:123'

url.format({protocol: 'https', hostname: 'google.com', port: '123'});
//=> 'https://google.com:123'

Related

  • url-parse-lax - Lax url.parse() with support for protocol-less URLs & IPs

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.0.0
    468
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 2.0.0
    468
  • 1.0.0
    2
  • 0.1.0
    0

Package Sidebar

Install

npm i url-format-lax

Weekly Downloads

470

Version

2.0.0

License

MIT

Unpacked Size

3.05 kB

Total Files

4

Last publish

Collaborators

  • sindresorhus