Light weight, universal, URL parser for node and the browser with built in caching.
npm install mini-url
import { parse, stringify } from 'mini-url'
// Parse a url into an object.
parse('http://host.com:8080/p/a/t/h?query=string#hash')
/* {
protocol: 'http:',
host: 'host.com:8080',
port: '8080',
hostname: 'host.com',
hash: '#hash',
search: '?query=string',
pathname: '/p/a/t/h',
href: 'http://host.com:8080/p/a/t/h?query=string#hash'
} */
// Stringify an object into a url string.
stringify({
protocol: 'http:',
host: 'host.com:8080',
hash: '#hash',
search: '?query=string',
pathname: '/p/a/t/h'
})
/* http://host.com:8080/p/a/t/h?query=string#hash */
- Use
npm test
to build and run tests.
Please feel free to create a PR!