diff --git a/dashboard-ui/bower_components/query-string/.bower.json b/dashboard-ui/bower_components/query-string/.bower.json new file mode 100644 index 0000000000..f71d674db3 --- /dev/null +++ b/dashboard-ui/bower_components/query-string/.bower.json @@ -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 +} \ No newline at end of file diff --git a/dashboard-ui/bower_components/query-string/.editorconfig b/dashboard-ui/bower_components/query-string/.editorconfig new file mode 100644 index 0000000000..8f9d77e2dc --- /dev/null +++ b/dashboard-ui/bower_components/query-string/.editorconfig @@ -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 diff --git a/dashboard-ui/bower_components/query-string/.gitattributes b/dashboard-ui/bower_components/query-string/.gitattributes new file mode 100644 index 0000000000..176a458f94 --- /dev/null +++ b/dashboard-ui/bower_components/query-string/.gitattributes @@ -0,0 +1 @@ +* text=auto diff --git a/dashboard-ui/bower_components/query-string/.gitignore b/dashboard-ui/bower_components/query-string/.gitignore new file mode 100644 index 0000000000..3c3629e647 --- /dev/null +++ b/dashboard-ui/bower_components/query-string/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/dashboard-ui/bower_components/query-string/.travis.yml b/dashboard-ui/bower_components/query-string/.travis.yml new file mode 100644 index 0000000000..52ba159be7 --- /dev/null +++ b/dashboard-ui/bower_components/query-string/.travis.yml @@ -0,0 +1,6 @@ +sudo: false +language: node_js +node_js: + - 'stable' + - '0.12' + - '0.10' diff --git a/dashboard-ui/bower_components/query-string/index.js b/dashboard-ui/bower_components/query-string/index.js new file mode 100644 index 0000000000..9c45f1d338 --- /dev/null +++ b/dashboard-ui/bower_components/query-string/index.js @@ -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('&') : ''; +}; diff --git a/dashboard-ui/bower_components/query-string/license b/dashboard-ui/bower_components/query-string/license new file mode 100644 index 0000000000..654d0bfe94 --- /dev/null +++ b/dashboard-ui/bower_components/query-string/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (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. diff --git a/dashboard-ui/bower_components/query-string/package.json b/dashboard-ui/bower_components/query-string/package.json new file mode 100644 index 0000000000..81e3f74a61 --- /dev/null +++ b/dashboard-ui/bower_components/query-string/package.json @@ -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": "*" + } +} diff --git a/dashboard-ui/bower_components/query-string/readme.md b/dashboard-ui/bower_components/query-string/readme.md new file mode 100644 index 0000000000..54064b7ef9 --- /dev/null +++ b/dashboard-ui/bower_components/query-string/readme.md @@ -0,0 +1,76 @@ +# 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 +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) diff --git a/dashboard-ui/bower_components/query-string/test/extract.js b/dashboard-ui/bower_components/query-string/test/extract.js new file mode 100644 index 0000000000..2434ab9341 --- /dev/null +++ b/dashboard-ui/bower_components/query-string/test/extract.js @@ -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); +}); diff --git a/dashboard-ui/bower_components/query-string/test/parse.js b/dashboard-ui/bower_components/query-string/test/parse.js new file mode 100644 index 0000000000..dba8bf1b84 --- /dev/null +++ b/dashboard-ui/bower_components/query-string/test/parse.js @@ -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'}); +}); diff --git a/dashboard-ui/bower_components/query-string/test/stringify.js b/dashboard-ui/bower_components/query-string/test/stringify.js new file mode 100644 index 0000000000..5866b2ce3c --- /dev/null +++ b/dashboard-ui/bower_components/query-string/test/stringify.js @@ -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'); +}); diff --git a/dashboard-ui/scripts/site.js b/dashboard-ui/scripts/site.js index 5499c264f9..8bc1d46c4e 100644 --- a/dashboard-ui/scripts/site.js +++ b/dashboard-ui/scripts/site.js @@ -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 {