1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
This commit is contained in:
Luke Pulverenti 2017-01-27 18:07:14 -05:00
parent 82bcca376f
commit 8a6884abef
494 changed files with 256 additions and 120180 deletions

View file

@ -1,15 +0,0 @@
{
"name": "query-string",
"homepage": "https://github.com/sindresorhus/query-string",
"version": "2.3.0",
"_release": "2.3.0",
"_resolution": {
"type": "version",
"tag": "2.3.0",
"commit": "89837373db79e73fb8bade647b46c188c69d761a"
},
"_source": "git://github.com/sindresorhus/query-string.git",
"_target": "~2.3.0",
"_originalSource": "query-string",
"_direct": true
}

View file

@ -1,15 +0,0 @@
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

View file

@ -1 +0,0 @@
* text=auto

View file

@ -1 +0,0 @@
node_modules

View file

@ -1,12 +0,0 @@
{
"node": true,
"esnext": true,
"bitwise": true,
"curly": true,
"immed": true,
"newcap": true,
"noarg": true,
"undef": true,
"unused": "vars",
"strict": true
}

View file

@ -1,6 +0,0 @@
sudo: false
language: node_js
node_js:
- 'iojs'
- '0.12'
- '0.10'

View file

@ -1,53 +1 @@
'use strict';
window.queryString = {};
window.queryString.extract = function (maybeUrl) {
return maybeUrl.split('?')[1] || '';
};
window.queryString.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('=');
var key = parts[0];
var val = parts[1];
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;
}, {});
};
window.queryString.stringify = function (obj) {
return obj ? Object.keys(obj).sort().map(function (key) {
var val = obj[key];
if (Array.isArray(val)) {
return val.sort().map(function (val2) {
return encodeURIComponent(key) + '=' + encodeURIComponent(val2);
}).join('&');
}
return encodeURIComponent(key) + '=' + encodeURIComponent(val);
}).join('&') : '';
};
"use strict";window.queryString={},window.queryString.extract=function(maybeUrl){return maybeUrl.split("?")[1]||""},window.queryString.parse=function(str){return"string"!=typeof str?{}:(str=str.trim().replace(/^(\?|#|&)/,""),str?str.split("&").reduce(function(ret,param){var parts=param.replace(/\+/g," ").split("="),key=parts[0],val=parts[1];return key=decodeURIComponent(key),val=void 0===val?null:decodeURIComponent(val),ret.hasOwnProperty(key)?Array.isArray(ret[key])?ret[key].push(val):ret[key]=[ret[key],val]:ret[key]=val,ret},{}):{})},window.queryString.stringify=function(obj){return obj?Object.keys(obj).sort().map(function(key){var val=obj[key];return Array.isArray(val)?val.sort().map(function(val2){return encodeURIComponent(key)+"="+encodeURIComponent(val2)}).join("&"):encodeURIComponent(key)+"="+encodeURIComponent(val)}).join("&"):""};

View file

@ -1,39 +0,0 @@
{
"name": "query-string",
"version": "2.3.0",
"description": "Parse and stringify URL query strings",
"keywords": [
"browser",
"querystring",
"query",
"string",
"qs",
"param",
"parameter",
"url",
"uri",
"parse",
"stringify",
"encode",
"decode"
],
"license": "MIT",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"files": [
"index.js"
],
"repository": "sindresorhus/query-string",
"scripts": {
"test": "mocha"
},
"devDependencies": {
"mocha": "*"
},
"engines": {
"node": ">=0.10.0"
}
}

View file

@ -1,76 +0,0 @@
# query-string [![Build Status](https://travis-ci.org/sindresorhus/query-string.svg?branch=master)](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
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](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)

View file

@ -1,91 +1 @@
'use strict';
var assert = require('assert');
var qs = require('./');
describe('.parse()', function () {
it('query strings starting with a `?`', function () {
assert.deepEqual(qs.parse('?foo=bar'), {foo: 'bar'});
});
it('query strings starting with a `#`', function () {
assert.deepEqual(qs.parse('#foo=bar'), {foo: 'bar'});
});
it('query strings starting with a `&', function () {
assert.deepEqual(qs.parse('&foo=bar&foo=baz'), {foo: ['bar', 'baz']});
});
it('parse a query string', function () {
assert.deepEqual(qs.parse('foo=bar'), {foo: 'bar'});
});
it('parse multiple query string', function () {
assert.deepEqual(qs.parse('foo=bar&key=val'), {foo: 'bar', key: 'val'});
});
it('parse query string without a value', function () {
assert.deepEqual(qs.parse('foo'), {foo: null});
assert.deepEqual(qs.parse('foo&key'), {foo: null, key: null});
assert.deepEqual(qs.parse('foo=bar&key'), {foo: 'bar', key: null});
});
it('return empty object if no qss can be found', function () {
assert.deepEqual(qs.parse('?'), {});
assert.deepEqual(qs.parse('&'), {});
assert.deepEqual(qs.parse('#'), {});
assert.deepEqual(qs.parse(' '), {});
});
it('handle `+` correctly', function () {
assert.deepEqual(qs.parse('foo+faz=bar+baz++'), {'foo faz': 'bar baz '});
});
it('handle multiple of the same key', function () {
assert.deepEqual(qs.parse('foo=bar&foo=baz'), {foo: ['bar', 'baz']});
});
it('query strings params including embedded `=`', function () {
assert.deepEqual(qs.parse('?param=http%3A%2F%2Fsomeurl%3Fid%3D2837'), {param: 'http://someurl?id=2837'});
});
});
describe('.stringify()', function () {
it('stringify', function () {
assert.strictEqual(qs.stringify({foo: 'bar'}), 'foo=bar');
assert.strictEqual(qs.stringify({foo: 'bar', bar: 'baz'}), 'bar=baz&foo=bar');
});
it('different types', function () {
assert.strictEqual(qs.stringify(), '');
assert.strictEqual(qs.stringify(0), '');
});
it('URI encode', function () {
assert.strictEqual(qs.stringify({'foo bar': 'baz faz'}), 'foo%20bar=baz%20faz');
});
it('handle array value', function () {
assert.strictEqual(qs.stringify({abc: 'abc', foo: ['bar', 'baz']}), 'abc=abc&foo=bar&foo=baz');
});
});
describe('.extract()', function () {
it('should extract qs from url', function () {
assert.equal(qs.extract('http://foo.bar/?abc=def&hij=klm'), 'abc=def&hij=klm');
assert.equal(qs.extract('http://foo.bar/?'), '');
});
it('should handle strings not containing qs', function () {
assert.equal(qs.extract('http://foo.bar/'), '');
assert.equal(qs.extract(''), '');
});
it('should throw for invalid values', function() {
assert.throws(function() {
qs.extract(null);
}, TypeError);
assert.throws(function() {
qs.extract(undefined);
}, TypeError);
});
});
"use strict";var assert=require("assert"),qs=require("./");describe(".parse()",function(){it("query strings starting with a `?`",function(){assert.deepEqual(qs.parse("?foo=bar"),{foo:"bar"})}),it("query strings starting with a `#`",function(){assert.deepEqual(qs.parse("#foo=bar"),{foo:"bar"})}),it("query strings starting with a `&",function(){assert.deepEqual(qs.parse("&foo=bar&foo=baz"),{foo:["bar","baz"]})}),it("parse a query string",function(){assert.deepEqual(qs.parse("foo=bar"),{foo:"bar"})}),it("parse multiple query string",function(){assert.deepEqual(qs.parse("foo=bar&key=val"),{foo:"bar",key:"val"})}),it("parse query string without a value",function(){assert.deepEqual(qs.parse("foo"),{foo:null}),assert.deepEqual(qs.parse("foo&key"),{foo:null,key:null}),assert.deepEqual(qs.parse("foo=bar&key"),{foo:"bar",key:null})}),it("return empty object if no qss can be found",function(){assert.deepEqual(qs.parse("?"),{}),assert.deepEqual(qs.parse("&"),{}),assert.deepEqual(qs.parse("#"),{}),assert.deepEqual(qs.parse(" "),{})}),it("handle `+` correctly",function(){assert.deepEqual(qs.parse("foo+faz=bar+baz++"),{"foo faz":"bar baz "})}),it("handle multiple of the same key",function(){assert.deepEqual(qs.parse("foo=bar&foo=baz"),{foo:["bar","baz"]})}),it("query strings params including embedded `=`",function(){assert.deepEqual(qs.parse("?param=http%3A%2F%2Fsomeurl%3Fid%3D2837"),{param:"http://someurl?id=2837"})})}),describe(".stringify()",function(){it("stringify",function(){assert.strictEqual(qs.stringify({foo:"bar"}),"foo=bar"),assert.strictEqual(qs.stringify({foo:"bar",bar:"baz"}),"bar=baz&foo=bar")}),it("different types",function(){assert.strictEqual(qs.stringify(),""),assert.strictEqual(qs.stringify(0),"")}),it("URI encode",function(){assert.strictEqual(qs.stringify({"foo bar":"baz faz"}),"foo%20bar=baz%20faz")}),it("handle array value",function(){assert.strictEqual(qs.stringify({abc:"abc",foo:["bar","baz"]}),"abc=abc&foo=bar&foo=baz")})}),describe(".extract()",function(){it("should extract qs from url",function(){assert.equal(qs.extract("http://foo.bar/?abc=def&hij=klm"),"abc=def&hij=klm"),assert.equal(qs.extract("http://foo.bar/?"),"")}),it("should handle strings not containing qs",function(){assert.equal(qs.extract("http://foo.bar/"),""),assert.equal(qs.extract(""),"")}),it("should throw for invalid values",function(){assert.throws(function(){qs.extract(null)},TypeError),assert.throws(function(){qs.extract(void 0)},TypeError)})});

View file

@ -1,17 +0,0 @@
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);
});

View file

@ -1,51 +0,0 @@
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'});
});

View file

@ -1,33 +0,0 @@
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');
});