Package Exports
- urlite
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (urlite) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
An extremely small, fast, dependency free url parser and formatter for nodejs and the web
- Very fast
- Very few lines of code
- Good test coverage
- Runs in node out of the box or in the browser with a module bundler such as browserify or webpack (commonjs)
usage
npm install --save urlite
var url = require('urlite')
url.parse('http://user:pass@blah.com:3000/path?query=string#fragment')
{
auth: 'user:pass',
hash: '#fragment',
host: 'blah.com:3000',
hostname: 'blah.com',
href: 'http://user:pass@blah.com:3000/path?query=string#fragment',
path: '/path?query=string',
pathname: '/path',
port: '3000',
protocol: 'http:',
query: 'query=string',
search: '?query=string'
}
var href = window.location.href
url.format(url.parse(href)) === href
// optional querystring parser/formatter (not bundled by default)
var querystring = require('urlite/querystring')
querystring.parse('?a=b&b=c') // -> { a: 'b', b: 'c'] }
querystring.format({ a: 'b', b: 'c'] }) // -> '?a=b&b=c'
// array support
querystring.parse('?a=b&a=c') // -> { a: ['b', 'c'] }
querystring.format({ a: ['b', 'c'] }) // -> '?a=b&a=c'