Skip to content

nuxt-contrib/xs-url

Repository files navigation

xs-url

JavaScript Style Guide

Installation

$ npm install --save xs-url

# or

$ yarn add xs-url

Usage

const url = require('xs-url')
const str = url.parse('http://www.example.com:8080/path/subpath?search=test#hs=hash')
/* {
  protocol: 'http',
  host: 'www.example.com',
  port: 8080,
  path: 'path/subpath',
  search: 'search=test',
  hash: 'hs=hash'
} */

url.format(str)
// http://www.example.com:8080/path/subpath?search=test#hs=hash

url.format(str, { search1: 'test1', search2: ['test2', 'test3'] })
// http://www.example.com:8080/path/subpath?search=test&search1=test1&search2=test2&search2=test3#hs=hash

About

Extremely small url parser

Resources

License

Stars

Watchers

Forks

Packages

No packages published