Skip to content

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

License

Notifications You must be signed in to change notification settings

sindresorhus/url-format-lax

Repository files navigation

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

About

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

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published