Skip to content

gaoryrt/url-param

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

url-param

switch between searchStr and paramsObj

Build Status codecov

install

$ npm install url-param

import

import { u } from 'url-param'

usage

paramsObj <=> searchStr

const searchStr = u({ q: '⭐' })
// => '?q=%E2%AD%90'

const paramsObj = u('?q=%E2%AD%90')
// => {q: "⭐"}

const urlObj = u('https://www.google.com/search?q=%E2%AD%90')
// => {q: "⭐"}

for current location.search

// say `location.search` is '?a=%21&%CE%B2=2'
u()         // => {a: "!", β: "2"}
  u('a')    // => '!'
  u().β     // => '2'
  u()['β']  // => '2'

License

MIT