npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

url-format-lax

1.0.0 • Public • Published

url-format-lax Build Status

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

Install

$ npm install --save url-format-lax

Usage

var urlFormatLax = require('url-format-lax');
 
urlFormatLax({hostname: '::1', port: '123'});
//=> '[::1]:123'
 
urlFormatLax({protocol: 'https', hostname: 'google.com', port: '123'});
//=> 'google.com:123'

And with the builtin url.format():

var url = require('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

License

MIT © Sindre Sorhus

install

npm i url-format-lax

Downloadsweekly downloads

30

version

1.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability