mini-url
TypeScript icon, indicating that this package has built-in type declarations

2.1.9 • Public • Published


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!

/mini-url/

    Package Sidebar

    Install

    npm i mini-url

    Weekly Downloads

    106

    Version

    2.1.9

    License

    MIT

    Last publish

    Collaborators

    • dylanpiercey