mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
add query string
This commit is contained in:
parent
ccf6b48bdc
commit
aa35c3ef4c
13 changed files with 349 additions and 0 deletions
76
dashboard-ui/bower_components/query-string/readme.md
vendored
Normal file
76
dashboard-ui/bower_components/query-string/readme.md
vendored
Normal file
|
@ -0,0 +1,76 @@
|
|||
# query-string [](https://travis-ci.org/sindresorhus/query-string)
|
||||
|
||||
> Parse and stringify URL [query strings](http://en.wikipedia.org/wiki/Query_string)
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save query-string
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
console.log(location.search);
|
||||
//=> '?foo=bar'
|
||||
|
||||
const parsed = queryString.parse(location.search);
|
||||
console.log(parsed);
|
||||
//=> {foo: 'bar'}
|
||||
|
||||
console.log(location.hash);
|
||||
//=> '#token=bada55cafe'
|
||||
|
||||
const 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 spec'd and varies between implementations, which causes a lot of [edge cases](https://github.com/visionmedia/node-querystring/issues).
|
||||
|
||||
You're much better off just converting the object to a JSON string:
|
||||
|
||||
```js
|
||||
queryString.stringify({
|
||||
foo: 'bar',
|
||||
nested: JSON.stringify({
|
||||
unicorn: 'cake'
|
||||
})
|
||||
});
|
||||
//=> 'foo=bar&nested=%7B%22unicorn%22%3A%22cake%22%7D'
|
||||
```
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](http://sindresorhus.com)
|
Loading…
Add table
Add a link
Reference in a new issue