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
15
dashboard-ui/bower_components/query-string/.bower.json
vendored
Normal file
15
dashboard-ui/bower_components/query-string/.bower.json
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"name": "query-string",
|
||||
"homepage": "https://github.com/sindresorhus/query-string",
|
||||
"version": "3.0.1",
|
||||
"_release": "3.0.1",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "v3.0.1",
|
||||
"commit": "9fbb928f67f493a7a7458cdb82c15b40ceb4124b"
|
||||
},
|
||||
"_source": "git://github.com/sindresorhus/query-string.git",
|
||||
"_target": "~3.0.1",
|
||||
"_originalSource": "query-string",
|
||||
"_direct": true
|
||||
}
|
15
dashboard-ui/bower_components/query-string/.editorconfig
vendored
Normal file
15
dashboard-ui/bower_components/query-string/.editorconfig
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = tab
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[{package.json,*.yml}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
1
dashboard-ui/bower_components/query-string/.gitattributes
vendored
Normal file
1
dashboard-ui/bower_components/query-string/.gitattributes
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
* text=auto
|
1
dashboard-ui/bower_components/query-string/.gitignore
vendored
Normal file
1
dashboard-ui/bower_components/query-string/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
node_modules
|
6
dashboard-ui/bower_components/query-string/.travis.yml
vendored
Normal file
6
dashboard-ui/bower_components/query-string/.travis.yml
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
sudo: false
|
||||
language: node_js
|
||||
node_js:
|
||||
- 'stable'
|
||||
- '0.12'
|
||||
- '0.10'
|
66
dashboard-ui/bower_components/query-string/index.js
vendored
Normal file
66
dashboard-ui/bower_components/query-string/index.js
vendored
Normal file
|
@ -0,0 +1,66 @@
|
|||
'use strict';
|
||||
var strictUriEncode = require('strict-uri-encode');
|
||||
|
||||
exports.extract = function (str) {
|
||||
return str.split('?')[1] || '';
|
||||
};
|
||||
|
||||
exports.parse = function (str) {
|
||||
if (typeof str !== 'string') {
|
||||
return {};
|
||||
}
|
||||
|
||||
str = str.trim().replace(/^(\?|#|&)/, '');
|
||||
|
||||
if (!str) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return str.split('&').reduce(function (ret, param) {
|
||||
var parts = param.replace(/\+/g, ' ').split('=');
|
||||
// Firefox (pre 40) decodes `%3D` to `=`
|
||||
// https://github.com/sindresorhus/query-string/pull/37
|
||||
var key = parts.shift();
|
||||
var val = parts.length > 0 ? parts.join('=') : undefined;
|
||||
|
||||
key = decodeURIComponent(key);
|
||||
|
||||
// missing `=` should be `null`:
|
||||
// http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters
|
||||
val = val === undefined ? null : decodeURIComponent(val);
|
||||
|
||||
if (!ret.hasOwnProperty(key)) {
|
||||
ret[key] = val;
|
||||
} else if (Array.isArray(ret[key])) {
|
||||
ret[key].push(val);
|
||||
} else {
|
||||
ret[key] = [ret[key], val];
|
||||
}
|
||||
|
||||
return ret;
|
||||
}, {});
|
||||
};
|
||||
|
||||
exports.stringify = function (obj) {
|
||||
return obj ? Object.keys(obj).sort().map(function (key) {
|
||||
var val = obj[key];
|
||||
|
||||
if (val === undefined) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (val === null) {
|
||||
return key;
|
||||
}
|
||||
|
||||
if (Array.isArray(val)) {
|
||||
return val.slice().sort().map(function (val2) {
|
||||
return strictUriEncode(key) + '=' + strictUriEncode(val2);
|
||||
}).join('&');
|
||||
}
|
||||
|
||||
return strictUriEncode(key) + '=' + strictUriEncode(val);
|
||||
}).filter(function (x) {
|
||||
return x.length > 0;
|
||||
}).join('&') : '';
|
||||
};
|
21
dashboard-ui/bower_components/query-string/license
vendored
Normal file
21
dashboard-ui/bower_components/query-string/license
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
43
dashboard-ui/bower_components/query-string/package.json
vendored
Normal file
43
dashboard-ui/bower_components/query-string/package.json
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
"name": "query-string",
|
||||
"version": "3.0.1",
|
||||
"description": "Parse and stringify URL query strings",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/query-string",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"browser",
|
||||
"querystring",
|
||||
"query",
|
||||
"string",
|
||||
"qs",
|
||||
"param",
|
||||
"parameter",
|
||||
"url",
|
||||
"uri",
|
||||
"parse",
|
||||
"stringify",
|
||||
"encode",
|
||||
"decode"
|
||||
],
|
||||
"dependencies": {
|
||||
"strict-uri-encode": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
}
|
||||
}
|
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)
|
17
dashboard-ui/bower_components/query-string/test/extract.js
vendored
Normal file
17
dashboard-ui/bower_components/query-string/test/extract.js
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
import test from 'ava';
|
||||
import fn from '../';
|
||||
|
||||
test('should extract query string from url', t => {
|
||||
t.is(fn.extract('http://foo.bar/?abc=def&hij=klm'), 'abc=def&hij=klm');
|
||||
t.is(fn.extract('http://foo.bar/?'), '');
|
||||
});
|
||||
|
||||
test('should handle strings not containing query string', t => {
|
||||
t.is(fn.extract('http://foo.bar/'), '');
|
||||
t.is(fn.extract(''), '');
|
||||
});
|
||||
|
||||
test('should throw for invalid values', t => {
|
||||
t.throws(fn.extract.bind(fn, null), TypeError);
|
||||
t.throws(fn.extract.bind(fn, undefined), TypeError);
|
||||
});
|
51
dashboard-ui/bower_components/query-string/test/parse.js
vendored
Normal file
51
dashboard-ui/bower_components/query-string/test/parse.js
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
import test from 'ava';
|
||||
import fn from '../';
|
||||
|
||||
test('query strings starting with a `?`', t => {
|
||||
t.same(fn.parse('?foo=bar'), {foo: 'bar'});
|
||||
});
|
||||
|
||||
test('query strings starting with a `#`', t => {
|
||||
t.same(fn.parse('#foo=bar'), {foo: 'bar'});
|
||||
});
|
||||
|
||||
test('query strings starting with a `&`', t => {
|
||||
t.same(fn.parse('&foo=bar&foo=baz'), {foo: ['bar', 'baz']});
|
||||
});
|
||||
|
||||
test('parse a query string', t => {
|
||||
t.same(fn.parse('foo=bar'), {foo: 'bar'});
|
||||
});
|
||||
|
||||
test('parse multiple query string', t => {
|
||||
t.same(fn.parse('foo=bar&key=val'), {foo: 'bar', key: 'val'});
|
||||
});
|
||||
|
||||
test('parse query string without a value', t => {
|
||||
t.same(fn.parse('foo'), {foo: null});
|
||||
t.same(fn.parse('foo&key'), {foo: null, key: null});
|
||||
t.same(fn.parse('foo=bar&key'), {foo: 'bar', key: null});
|
||||
});
|
||||
|
||||
test('return empty object if no qss can be found', t => {
|
||||
t.same(fn.parse('?'), {});
|
||||
t.same(fn.parse('&'), {});
|
||||
t.same(fn.parse('#'), {});
|
||||
t.same(fn.parse(' '), {});
|
||||
});
|
||||
|
||||
test('handle `+` correctly', t => {
|
||||
t.same(fn.parse('foo+faz=bar+baz++'), {'foo faz': 'bar baz '});
|
||||
});
|
||||
|
||||
test('handle multiple of the same key', t => {
|
||||
t.same(fn.parse('foo=bar&foo=baz'), {foo: ['bar', 'baz']});
|
||||
});
|
||||
|
||||
test('query strings params including embedded `=`', t => {
|
||||
t.same(fn.parse('?param=http%3A%2F%2Fsomeurl%3Fid%3D2837'), {param: 'http://someurl?id=2837'});
|
||||
});
|
||||
|
||||
test('query strings params including raw `=`', t => {
|
||||
t.same(fn.parse('?param=http://someurl?id=2837'), {param: 'http://someurl?id=2837'});
|
||||
});
|
33
dashboard-ui/bower_components/query-string/test/stringify.js
vendored
Normal file
33
dashboard-ui/bower_components/query-string/test/stringify.js
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
import test from 'ava';
|
||||
import fn from '../';
|
||||
|
||||
test('stringify', t => {
|
||||
t.same(fn.stringify({foo: 'bar'}), 'foo=bar');
|
||||
t.same(fn.stringify({foo: 'bar', bar: 'baz'}), 'bar=baz&foo=bar');
|
||||
});
|
||||
|
||||
test('different types', t => {
|
||||
t.same(fn.stringify(), '');
|
||||
t.same(fn.stringify(0), '');
|
||||
});
|
||||
|
||||
test('URI encode', t => {
|
||||
t.same(fn.stringify({'foo bar': 'baz faz'}), 'foo%20bar=baz%20faz');
|
||||
t.same(fn.stringify({'foo bar': 'baz\'faz'}), 'foo%20bar=baz%27faz');
|
||||
});
|
||||
|
||||
test('handle array value', t => {
|
||||
t.same(fn.stringify({abc: 'abc', foo: ['bar', 'baz']}), 'abc=abc&foo=bar&foo=baz');
|
||||
});
|
||||
|
||||
test('handle empty array value', t => {
|
||||
t.same(fn.stringify({abc: 'abc', foo: []}), 'abc=abc');
|
||||
});
|
||||
|
||||
test('should not encode undefined values', t => {
|
||||
t.same(fn.stringify({abc: undefined, foo: 'baz'}), 'foo=baz');
|
||||
});
|
||||
|
||||
test('should encode null values as just a key', t => {
|
||||
t.same(fn.stringify({xyz: null, abc: null, foo: 'baz'}), 'abc&foo=baz&xyz');
|
||||
});
|
|
@ -1919,6 +1919,10 @@ var AppInfo = {};
|
|||
define("opensansFont", ['css!' + embyWebComponentsBowerPath + '/fonts/opensans/style']);
|
||||
define("montserratFont", ['css!' + embyWebComponentsBowerPath + '/fonts/montserrat/style']);
|
||||
|
||||
define('queryString', ['bower_components/query-string/index'], function () {
|
||||
return queryString;
|
||||
});
|
||||
|
||||
// alias
|
||||
define("historyManager", [], function () {
|
||||
return {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue