Parse the password and user out of a url. Do in one step what would take two steps and a string.split with
require('url')
.
$ npm install --save url-parse-auth
var urlParseAuth = require('url-parse-auth')
urlParseAuth('https://user:pass@baz.com')
//=> {user: 'user', pass: 'pass'}
Both user
and password
will be undefined if the url has no auth section.
MIT © Andrew Joslin