uqs

1.0.0 • Public • Published

uqs

Microscopically small querystring parser/stringifier

npm license travis greenkeeper mind BLOWN

.

uqs is a microscopically small universal querystring parser/stringifier.

Install

npm install --save uqs

require

var QS = require('uqs')

import

import QS from 'uqs'

use

var params = QS.parse(location.search)
// or the other way around
var qs = QS.stringify({my:'querystring', arguments:2})

why

Modern browsers make parsing URLs simple:

var link = document.createElement('a')
link.href = 'https://example.com/some/path?they=did&forget=something'
console.info(link.protocol)  // >  'https:'
console.info(link.hostname)  // >  'example.com'
console.info(link.pathname)  // >  '/some/path'

You get the picture. So all is well...

or not? There is this one thing they seemed to have forgotten:

console.info(link.search)  // >  '?they=did&forget=something'  <== YUCK!

Darn it, now we still need to parse by hand!

uqs to the resque!

uqs is a microscopically small (< 1 kB minified and gzipped) querystring parser and minifier that fills this exact gap the browser makers left us:

var QS = require('uqs')
var params = QS.parse(link.search)
console.info(params)      // >  Object {they: "did", forget: "something"}

Issues

Add an issue in this project's issue tracker to let me know of any problems you find, or questions you may have.

Copyright

Copyright 2016 by Stijn de Witt. Some rights reserved.

License

Licensed under the Creative Commons Attribution 4.0 International (CC-BY-4.0) Open Source license.

Readme

Keywords

Package Sidebar

Install

npm i uqs

Weekly Downloads

5

Version

1.0.0

License

CC-BY-4.0

Last publish

Collaborators

  • stijndewitt