Lightweight isomorphic url parser.


Keywords
URL, isomorphic, mini, parse, resolve, universal, mini-url, parser, url-parser
License
MIT
Install
npm install mini-url@2.0.3

Documentation


Mini-URL
API Stability TypeScript Styled with prettier Build status Test Coverage NPM Version Downloads Browser Bundle Size

Light weight, universal, URL parser for node and the browser with built in caching.

Installation

npm install mini-url

Example

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 */

Contributions

  • Use npm test to build and run tests.

Please feel free to create a PR!