jellyfin-web/dashboard-ui/bower_components/query-string
2016-03-14 16:27:35 -04:00
..
test add query string 2016-03-14 16:00:18 -04:00
.bower.json update shared components 2016-03-14 16:27:35 -04:00
.editorconfig add query string 2016-03-14 16:00:18 -04:00
.gitattributes add query string 2016-03-14 16:00:18 -04:00
.gitignore add query string 2016-03-14 16:00:18 -04:00
.jshintrc update shared components 2016-03-14 16:27:35 -04:00
.travis.yml update shared components 2016-03-14 16:27:35 -04:00
index.js update shared components 2016-03-14 16:27:35 -04:00
license add query string 2016-03-14 16:00:18 -04:00
package.json update shared components 2016-03-14 16:27:35 -04:00
readme.md update shared components 2016-03-14 16:27:35 -04:00
test.js update shared components 2016-03-14 16:27:35 -04:00

query-string Build Status

Parse and stringify URL query strings

Install

$ npm install --save query-string

Usage

var queryString = require('query-string');

console.log(location.search);
//=> ?foo=bar

var parsed = queryString.parse(location.search);
console.log(parsed);
//=> {foo: 'bar'}

console.log(location.hash);
//=> #token=bada55cafe

var parsedHash = queryString.parse(location.hash);
console.log(parsedHash);
//=> {token: 'bada55cafe'}

parsed.foo = 'unicorn';
parsed.ilike = 'pizza';

location.search = queryString.stringify(parsed);

console.log(location.search);
//=> ?foo=unicorn&ilike=pizza

API

.parse(string)

Parse a query string into an object. Leading ? or # are ignored, so you can pass location.search or location.hash directly.

.stringify(object)

Stringify an object into a query string, sorting the keys.

.extract(string)

Extract a query string from a URL that can be passed into .parse().

Nesting

This module intentionally doesn't support nesting as it's not specced and varies between implementations, which causes a lot of edge cases.

You're much better off just converting the object to a JSON string:

queryString.stringify({
	foo: 'bar',
	nested: JSON.stringify({
		unicorn: 'cake'
	})
});
//=> foo=bar&nested=%7B%22unicorn%22%3A%22cake%22%7D

License

MIT © Sindre Sorhus