npm

Bring the best of OSS JavaScript development to your projects with npm Orgs - private packages & team management tools.Learn more »

format-url

1.1.0 • Public • Published

format-url

Light wrapper around Node.js url.format() to reduce the number of checks you need to do before calling it. Designed to detect protocol and path (or lack thereof), but still get the result you expect from url.format().

Usage

$ npm install format-url
$ node
> var urlFormat = require('format-url');
undefined
> urlFormat('127.0.0.0');
'http://127.0.0.0'
> urlFormat('127.0.0.0:8080');
'http://127.0.0.0:8080'
> urlFormat('http://127.0.0.0:8080');
'http://127.0.0.0:8080'
> urlFormat('https://127.0.0.0:8080');
'https://127.0.0.0:8080'
> urlFormat('127.0.0.0:8080/path/to/things');
'http://127.0.0.0:8080/path/to/things'

Tests can be found in the test/ directory.

Licence

ISC

install

npm i format-url

Downloadsweekly downloads

70

version

1.1.0

license

ISC

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability