unit tests, and some cleaning up
This commit is contained in:
22
node_modules/url-parse/LICENSE
generated
vendored
Normal file
22
node_modules/url-parse/LICENSE
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Unshift.io, Arnout Kazemier, the Contributors.
|
||||
|
||||
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.
|
||||
|
147
node_modules/url-parse/README.md
generated
vendored
Normal file
147
node_modules/url-parse/README.md
generated
vendored
Normal file
@ -0,0 +1,147 @@
|
||||
# url-parse
|
||||
|
||||
[](http://unshift.io)[](https://www.npmjs.com/package/url-parse)[](https://travis-ci.org/unshiftio/url-parse)[](https://david-dm.org/unshiftio/url-parse)[](https://coveralls.io/r/unshiftio/url-parse?branch=master)[](https://webchat.freenode.net/?channels=unshift)
|
||||
|
||||
[](https://saucelabs.com/u/url-parse)
|
||||
|
||||
The `url-parse` method exposes two different API interfaces. The
|
||||
[`url`](https://nodejs.org/api/url.html) interface that you know from Node.js
|
||||
and the new [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL)
|
||||
interface that is available in the latest browsers.
|
||||
|
||||
In version `0.1` we moved from a DOM based parsing solution, using the `<a>`
|
||||
element, to a full Regular Expression solution. The main reason for this was
|
||||
to make the URL parser available in different JavaScript environments as you
|
||||
don't always have access to the DOM. An example of such environment is the
|
||||
[`Worker`](https://developer.mozilla.org/en/docs/Web/API/Worker) interface.
|
||||
The RegExp based solution didn't work well as it required a lot of lookups
|
||||
causing major problems in FireFox. In version `1.0.0` we ditched the RegExp
|
||||
based solution in favor of a pure string parsing solution which chops up the
|
||||
URL into smaller pieces. This module still has a really small footprint as it
|
||||
has been designed to be used on the client side.
|
||||
|
||||
In addition to URL parsing we also expose the bundled `querystringify` module.
|
||||
|
||||
## Installation
|
||||
|
||||
This module is designed to be used using either browserify or Node.js it's
|
||||
released in the public npm registry and can be installed using:
|
||||
|
||||
```
|
||||
npm install url-parse
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
All examples assume that this library is bootstrapped using:
|
||||
|
||||
```js
|
||||
'use strict';
|
||||
|
||||
var Url = require('url-parse');
|
||||
```
|
||||
|
||||
To parse an URL simply call the `URL` method with the URL that needs to be
|
||||
transformed into an object.
|
||||
|
||||
```js
|
||||
var url = new Url('https://github.com/foo/bar');
|
||||
```
|
||||
|
||||
The `new` keyword is optional but it will save you an extra function invocation.
|
||||
The constructor takes the following arguments:
|
||||
|
||||
- `url` (`String`): A string representing an absolute or relative URL.
|
||||
- `baseURL` (`Object` | `String`): An object or string representing
|
||||
the base URL to use in case `url` is a relative URL. This argument is
|
||||
optional and defaults to [`location`](https://developer.mozilla.org/en-US/docs/Web/API/Location)
|
||||
in the browser.
|
||||
- `parser` (`Boolean` | `Function`): This argument is optional and specifies
|
||||
how to parse the query string. By default it is `false` so the query string
|
||||
is not parsed. If you pass `true` the query string is parsed using the
|
||||
embedded `querystringify` module. If you pass a function the query string
|
||||
will be parsed using this function.
|
||||
|
||||
As said above we also support the Node.js interface so you can also use the
|
||||
library in this way:
|
||||
|
||||
```js
|
||||
'use strict';
|
||||
|
||||
var parse = require('url-parse')
|
||||
, url = parse('https://github.com/foo/bar', true);
|
||||
```
|
||||
|
||||
The returned `url` instance contains the following properties:
|
||||
|
||||
- `protocol`: The protocol scheme of the URL (e.g. `http:`).
|
||||
- `slashes`: A boolean which indicates whether the `protocol` is followed by two
|
||||
forward slashes (`//`).
|
||||
- `auth`: Authentication information portion (e.g. `username:password`).
|
||||
- `username`: Username of basic authentication.
|
||||
- `password`: Password of basic authentication.
|
||||
- `host`: Host name with port number.
|
||||
- `hostname`: Host name without port number.
|
||||
- `port`: Optional port number.
|
||||
- `pathname`: URL path.
|
||||
- `query`: Parsed object containing query string, unless parsing is set to false.
|
||||
- `hash`: The "fragment" portion of the URL including the pound-sign (`#`).
|
||||
- `href`: The full URL.
|
||||
- `origin`: The origin of the URL.
|
||||
|
||||
Note that when `url-parse` is used in a browser environment, it will default to
|
||||
using the browser's current window location as the base URL when parsing all
|
||||
inputs. To parse an input independently of the browser's current URL (e.g. for
|
||||
functionality parity with the library in a Node environment), pass an empty
|
||||
location object as the second parameter:
|
||||
|
||||
```js
|
||||
var parse = require('url-parse');
|
||||
parse('hostname', {});
|
||||
```
|
||||
|
||||
### Url.set(key, value)
|
||||
|
||||
A simple helper function to change parts of the URL and propagating it through
|
||||
all properties. When you set a new `host` you want the same value to be applied
|
||||
to `port` if has a different port number, `hostname` so it has a correct name
|
||||
again and `href` so you have a complete URL.
|
||||
|
||||
```js
|
||||
var parsed = parse('http://google.com/parse-things');
|
||||
|
||||
parsed.set('hostname', 'yahoo.com');
|
||||
console.log(parsed.href); // http://yahoo.com/parse-things
|
||||
```
|
||||
|
||||
It's aware of default ports so you cannot set a port 80 on an URL which has
|
||||
`http` as protocol.
|
||||
|
||||
### Url.toString()
|
||||
|
||||
The returned `url` object comes with a custom `toString` method which will
|
||||
generate a full URL again when called. The method accepts an extra function
|
||||
which will stringify the query string for you. If you don't supply a function we
|
||||
will use our default method.
|
||||
|
||||
```js
|
||||
var location = url.toString(); // http://example.com/whatever/?qs=32
|
||||
```
|
||||
|
||||
You would rarely need to use this method as the full URL is also available as
|
||||
`href` property. If you are using the `URL.set` method to make changes, this
|
||||
will automatically update.
|
||||
|
||||
## Testing
|
||||
|
||||
The testing of this module is done in 3 different ways:
|
||||
|
||||
1. We have unit tests that run under Node.js. You can run these tests with the
|
||||
`npm test` command.
|
||||
2. Code coverage can be run manually using `npm run coverage`.
|
||||
3. For browser testing we use Sauce Labs and `zuul`. You can run browser tests
|
||||
using the `npm run test-browser` command.
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
555
node_modules/url-parse/dist/url-parse.js
generated
vendored
Normal file
555
node_modules/url-parse/dist/url-parse.js
generated
vendored
Normal file
@ -0,0 +1,555 @@
|
||||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.URLParse = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
||||
(function (global){
|
||||
'use strict';
|
||||
|
||||
var required = require('requires-port')
|
||||
, qs = require('querystringify')
|
||||
, protocolre = /^([a-z][a-z0-9.+-]*:)?(\/\/)?([\S\s]*)/i
|
||||
, slashes = /^[A-Za-z][A-Za-z0-9+-.]*:\/\//;
|
||||
|
||||
/**
|
||||
* These are the parse rules for the URL parser, it informs the parser
|
||||
* about:
|
||||
*
|
||||
* 0. The char it Needs to parse, if it's a string it should be done using
|
||||
* indexOf, RegExp using exec and NaN means set as current value.
|
||||
* 1. The property we should set when parsing this value.
|
||||
* 2. Indication if it's backwards or forward parsing, when set as number it's
|
||||
* the value of extra chars that should be split off.
|
||||
* 3. Inherit from location if non existing in the parser.
|
||||
* 4. `toLowerCase` the resulting value.
|
||||
*/
|
||||
var rules = [
|
||||
['#', 'hash'], // Extract from the back.
|
||||
['?', 'query'], // Extract from the back.
|
||||
function sanitize(address) { // Sanitize what is left of the address
|
||||
return address.replace('\\', '/');
|
||||
},
|
||||
['/', 'pathname'], // Extract from the back.
|
||||
['@', 'auth', 1], // Extract from the front.
|
||||
[NaN, 'host', undefined, 1, 1], // Set left over value.
|
||||
[/:(\d+)$/, 'port', undefined, 1], // RegExp the back.
|
||||
[NaN, 'hostname', undefined, 1, 1] // Set left over.
|
||||
];
|
||||
|
||||
/**
|
||||
* These properties should not be copied or inherited from. This is only needed
|
||||
* for all non blob URL's as a blob URL does not include a hash, only the
|
||||
* origin.
|
||||
*
|
||||
* @type {Object}
|
||||
* @private
|
||||
*/
|
||||
var ignore = { hash: 1, query: 1 };
|
||||
|
||||
/**
|
||||
* The location object differs when your code is loaded through a normal page,
|
||||
* Worker or through a worker using a blob. And with the blobble begins the
|
||||
* trouble as the location object will contain the URL of the blob, not the
|
||||
* location of the page where our code is loaded in. The actual origin is
|
||||
* encoded in the `pathname` so we can thankfully generate a good "default"
|
||||
* location from it so we can generate proper relative URL's again.
|
||||
*
|
||||
* @param {Object|String} loc Optional default location object.
|
||||
* @returns {Object} lolcation object.
|
||||
* @public
|
||||
*/
|
||||
function lolcation(loc) {
|
||||
var globalVar;
|
||||
|
||||
if (typeof window !== 'undefined') globalVar = window;
|
||||
else if (typeof global !== 'undefined') globalVar = global;
|
||||
else if (typeof self !== 'undefined') globalVar = self;
|
||||
else globalVar = {};
|
||||
|
||||
var location = globalVar.location || {};
|
||||
loc = loc || location;
|
||||
|
||||
var finaldestination = {}
|
||||
, type = typeof loc
|
||||
, key;
|
||||
|
||||
if ('blob:' === loc.protocol) {
|
||||
finaldestination = new Url(unescape(loc.pathname), {});
|
||||
} else if ('string' === type) {
|
||||
finaldestination = new Url(loc, {});
|
||||
for (key in ignore) delete finaldestination[key];
|
||||
} else if ('object' === type) {
|
||||
for (key in loc) {
|
||||
if (key in ignore) continue;
|
||||
finaldestination[key] = loc[key];
|
||||
}
|
||||
|
||||
if (finaldestination.slashes === undefined) {
|
||||
finaldestination.slashes = slashes.test(loc.href);
|
||||
}
|
||||
}
|
||||
|
||||
return finaldestination;
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef ProtocolExtract
|
||||
* @type Object
|
||||
* @property {String} protocol Protocol matched in the URL, in lowercase.
|
||||
* @property {Boolean} slashes `true` if protocol is followed by "//", else `false`.
|
||||
* @property {String} rest Rest of the URL that is not part of the protocol.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Extract protocol information from a URL with/without double slash ("//").
|
||||
*
|
||||
* @param {String} address URL we want to extract from.
|
||||
* @return {ProtocolExtract} Extracted information.
|
||||
* @private
|
||||
*/
|
||||
function extractProtocol(address) {
|
||||
var match = protocolre.exec(address);
|
||||
|
||||
return {
|
||||
protocol: match[1] ? match[1].toLowerCase() : '',
|
||||
slashes: !!match[2],
|
||||
rest: match[3]
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a relative URL pathname against a base URL pathname.
|
||||
*
|
||||
* @param {String} relative Pathname of the relative URL.
|
||||
* @param {String} base Pathname of the base URL.
|
||||
* @return {String} Resolved pathname.
|
||||
* @private
|
||||
*/
|
||||
function resolve(relative, base) {
|
||||
var path = (base || '/').split('/').slice(0, -1).concat(relative.split('/'))
|
||||
, i = path.length
|
||||
, last = path[i - 1]
|
||||
, unshift = false
|
||||
, up = 0;
|
||||
|
||||
while (i--) {
|
||||
if (path[i] === '.') {
|
||||
path.splice(i, 1);
|
||||
} else if (path[i] === '..') {
|
||||
path.splice(i, 1);
|
||||
up++;
|
||||
} else if (up) {
|
||||
if (i === 0) unshift = true;
|
||||
path.splice(i, 1);
|
||||
up--;
|
||||
}
|
||||
}
|
||||
|
||||
if (unshift) path.unshift('');
|
||||
if (last === '.' || last === '..') path.push('');
|
||||
|
||||
return path.join('/');
|
||||
}
|
||||
|
||||
/**
|
||||
* The actual URL instance. Instead of returning an object we've opted-in to
|
||||
* create an actual constructor as it's much more memory efficient and
|
||||
* faster and it pleases my OCD.
|
||||
*
|
||||
* It is worth noting that we should not use `URL` as class name to prevent
|
||||
* clashes with the global URL instance that got introduced in browsers.
|
||||
*
|
||||
* @constructor
|
||||
* @param {String} address URL we want to parse.
|
||||
* @param {Object|String} [location] Location defaults for relative paths.
|
||||
* @param {Boolean|Function} [parser] Parser for the query string.
|
||||
* @private
|
||||
*/
|
||||
function Url(address, location, parser) {
|
||||
if (!(this instanceof Url)) {
|
||||
return new Url(address, location, parser);
|
||||
}
|
||||
|
||||
var relative, extracted, parse, instruction, index, key
|
||||
, instructions = rules.slice()
|
||||
, type = typeof location
|
||||
, url = this
|
||||
, i = 0;
|
||||
|
||||
//
|
||||
// The following if statements allows this module two have compatibility with
|
||||
// 2 different API:
|
||||
//
|
||||
// 1. Node.js's `url.parse` api which accepts a URL, boolean as arguments
|
||||
// where the boolean indicates that the query string should also be parsed.
|
||||
//
|
||||
// 2. The `URL` interface of the browser which accepts a URL, object as
|
||||
// arguments. The supplied object will be used as default values / fall-back
|
||||
// for relative paths.
|
||||
//
|
||||
if ('object' !== type && 'string' !== type) {
|
||||
parser = location;
|
||||
location = null;
|
||||
}
|
||||
|
||||
if (parser && 'function' !== typeof parser) parser = qs.parse;
|
||||
|
||||
location = lolcation(location);
|
||||
|
||||
//
|
||||
// Extract protocol information before running the instructions.
|
||||
//
|
||||
extracted = extractProtocol(address || '');
|
||||
relative = !extracted.protocol && !extracted.slashes;
|
||||
url.slashes = extracted.slashes || relative && location.slashes;
|
||||
url.protocol = extracted.protocol || location.protocol || '';
|
||||
address = extracted.rest;
|
||||
|
||||
//
|
||||
// When the authority component is absent the URL starts with a path
|
||||
// component.
|
||||
//
|
||||
if (!extracted.slashes) instructions[3] = [/(.*)/, 'pathname'];
|
||||
|
||||
for (; i < instructions.length; i++) {
|
||||
instruction = instructions[i];
|
||||
|
||||
if (typeof instruction === 'function') {
|
||||
address = instruction(address);
|
||||
continue;
|
||||
}
|
||||
|
||||
parse = instruction[0];
|
||||
key = instruction[1];
|
||||
|
||||
if (parse !== parse) {
|
||||
url[key] = address;
|
||||
} else if ('string' === typeof parse) {
|
||||
if (~(index = address.indexOf(parse))) {
|
||||
if ('number' === typeof instruction[2]) {
|
||||
url[key] = address.slice(0, index);
|
||||
address = address.slice(index + instruction[2]);
|
||||
} else {
|
||||
url[key] = address.slice(index);
|
||||
address = address.slice(0, index);
|
||||
}
|
||||
}
|
||||
} else if ((index = parse.exec(address))) {
|
||||
url[key] = index[1];
|
||||
address = address.slice(0, index.index);
|
||||
}
|
||||
|
||||
url[key] = url[key] || (
|
||||
relative && instruction[3] ? location[key] || '' : ''
|
||||
);
|
||||
|
||||
//
|
||||
// Hostname, host and protocol should be lowercased so they can be used to
|
||||
// create a proper `origin`.
|
||||
//
|
||||
if (instruction[4]) url[key] = url[key].toLowerCase();
|
||||
}
|
||||
|
||||
//
|
||||
// Also parse the supplied query string in to an object. If we're supplied
|
||||
// with a custom parser as function use that instead of the default build-in
|
||||
// parser.
|
||||
//
|
||||
if (parser) url.query = parser(url.query);
|
||||
|
||||
//
|
||||
// If the URL is relative, resolve the pathname against the base URL.
|
||||
//
|
||||
if (
|
||||
relative
|
||||
&& location.slashes
|
||||
&& url.pathname.charAt(0) !== '/'
|
||||
&& (url.pathname !== '' || location.pathname !== '')
|
||||
) {
|
||||
url.pathname = resolve(url.pathname, location.pathname);
|
||||
}
|
||||
|
||||
//
|
||||
// We should not add port numbers if they are already the default port number
|
||||
// for a given protocol. As the host also contains the port number we're going
|
||||
// override it with the hostname which contains no port number.
|
||||
//
|
||||
if (!required(url.port, url.protocol)) {
|
||||
url.host = url.hostname;
|
||||
url.port = '';
|
||||
}
|
||||
|
||||
//
|
||||
// Parse down the `auth` for the username and password.
|
||||
//
|
||||
url.username = url.password = '';
|
||||
if (url.auth) {
|
||||
instruction = url.auth.split(':');
|
||||
url.username = instruction[0] || '';
|
||||
url.password = instruction[1] || '';
|
||||
}
|
||||
|
||||
url.origin = url.protocol && url.host && url.protocol !== 'file:'
|
||||
? url.protocol +'//'+ url.host
|
||||
: 'null';
|
||||
|
||||
//
|
||||
// The href is just the compiled result.
|
||||
//
|
||||
url.href = url.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* This is convenience method for changing properties in the URL instance to
|
||||
* insure that they all propagate correctly.
|
||||
*
|
||||
* @param {String} part Property we need to adjust.
|
||||
* @param {Mixed} value The newly assigned value.
|
||||
* @param {Boolean|Function} fn When setting the query, it will be the function
|
||||
* used to parse the query.
|
||||
* When setting the protocol, double slash will be
|
||||
* removed from the final url if it is true.
|
||||
* @returns {URL} URL instance for chaining.
|
||||
* @public
|
||||
*/
|
||||
function set(part, value, fn) {
|
||||
var url = this;
|
||||
|
||||
switch (part) {
|
||||
case 'query':
|
||||
if ('string' === typeof value && value.length) {
|
||||
value = (fn || qs.parse)(value);
|
||||
}
|
||||
|
||||
url[part] = value;
|
||||
break;
|
||||
|
||||
case 'port':
|
||||
url[part] = value;
|
||||
|
||||
if (!required(value, url.protocol)) {
|
||||
url.host = url.hostname;
|
||||
url[part] = '';
|
||||
} else if (value) {
|
||||
url.host = url.hostname +':'+ value;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'hostname':
|
||||
url[part] = value;
|
||||
|
||||
if (url.port) value += ':'+ url.port;
|
||||
url.host = value;
|
||||
break;
|
||||
|
||||
case 'host':
|
||||
url[part] = value;
|
||||
|
||||
if (/:\d+$/.test(value)) {
|
||||
value = value.split(':');
|
||||
url.port = value.pop();
|
||||
url.hostname = value.join(':');
|
||||
} else {
|
||||
url.hostname = value;
|
||||
url.port = '';
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'protocol':
|
||||
url.protocol = value.toLowerCase();
|
||||
url.slashes = !fn;
|
||||
break;
|
||||
|
||||
case 'pathname':
|
||||
case 'hash':
|
||||
if (value) {
|
||||
var char = part === 'pathname' ? '/' : '#';
|
||||
url[part] = value.charAt(0) !== char ? char + value : value;
|
||||
} else {
|
||||
url[part] = value;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
url[part] = value;
|
||||
}
|
||||
|
||||
for (var i = 0; i < rules.length; i++) {
|
||||
var ins = rules[i];
|
||||
|
||||
if (ins[4]) url[ins[1]] = url[ins[1]].toLowerCase();
|
||||
}
|
||||
|
||||
url.origin = url.protocol && url.host && url.protocol !== 'file:'
|
||||
? url.protocol +'//'+ url.host
|
||||
: 'null';
|
||||
|
||||
url.href = url.toString();
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform the properties back in to a valid and full URL string.
|
||||
*
|
||||
* @param {Function} stringify Optional query stringify function.
|
||||
* @returns {String} Compiled version of the URL.
|
||||
* @public
|
||||
*/
|
||||
function toString(stringify) {
|
||||
if (!stringify || 'function' !== typeof stringify) stringify = qs.stringify;
|
||||
|
||||
var query
|
||||
, url = this
|
||||
, protocol = url.protocol;
|
||||
|
||||
if (protocol && protocol.charAt(protocol.length - 1) !== ':') protocol += ':';
|
||||
|
||||
var result = protocol + (url.slashes ? '//' : '');
|
||||
|
||||
if (url.username) {
|
||||
result += url.username;
|
||||
if (url.password) result += ':'+ url.password;
|
||||
result += '@';
|
||||
}
|
||||
|
||||
result += url.host + url.pathname;
|
||||
|
||||
query = 'object' === typeof url.query ? stringify(url.query) : url.query;
|
||||
if (query) result += '?' !== query.charAt(0) ? '?'+ query : query;
|
||||
|
||||
if (url.hash) result += url.hash;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Url.prototype = { set: set, toString: toString };
|
||||
|
||||
//
|
||||
// Expose the URL parser and some additional properties that might be useful for
|
||||
// others or testing.
|
||||
//
|
||||
Url.extractProtocol = extractProtocol;
|
||||
Url.location = lolcation;
|
||||
Url.qs = qs;
|
||||
|
||||
module.exports = Url;
|
||||
|
||||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
||||
},{"querystringify":2,"requires-port":3}],2:[function(require,module,exports){
|
||||
'use strict';
|
||||
|
||||
var has = Object.prototype.hasOwnProperty;
|
||||
|
||||
/**
|
||||
* Decode a URI encoded string.
|
||||
*
|
||||
* @param {String} input The URI encoded string.
|
||||
* @returns {String} The decoded string.
|
||||
* @api private
|
||||
*/
|
||||
function decode(input) {
|
||||
return decodeURIComponent(input.replace(/\+/g, ' '));
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple query string parser.
|
||||
*
|
||||
* @param {String} query The query string that needs to be parsed.
|
||||
* @returns {Object}
|
||||
* @api public
|
||||
*/
|
||||
function querystring(query) {
|
||||
var parser = /([^=?&]+)=?([^&]*)/g
|
||||
, result = {}
|
||||
, part;
|
||||
|
||||
while (part = parser.exec(query)) {
|
||||
var key = decode(part[1])
|
||||
, value = decode(part[2]);
|
||||
|
||||
//
|
||||
// Prevent overriding of existing properties. This ensures that build-in
|
||||
// methods like `toString` or __proto__ are not overriden by malicious
|
||||
// querystrings.
|
||||
//
|
||||
if (key in result) continue;
|
||||
result[key] = value;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform a query string to an object.
|
||||
*
|
||||
* @param {Object} obj Object that should be transformed.
|
||||
* @param {String} prefix Optional prefix.
|
||||
* @returns {String}
|
||||
* @api public
|
||||
*/
|
||||
function querystringify(obj, prefix) {
|
||||
prefix = prefix || '';
|
||||
|
||||
var pairs = [];
|
||||
|
||||
//
|
||||
// Optionally prefix with a '?' if needed
|
||||
//
|
||||
if ('string' !== typeof prefix) prefix = '?';
|
||||
|
||||
for (var key in obj) {
|
||||
if (has.call(obj, key)) {
|
||||
pairs.push(encodeURIComponent(key) +'='+ encodeURIComponent(obj[key]));
|
||||
}
|
||||
}
|
||||
|
||||
return pairs.length ? prefix + pairs.join('&') : '';
|
||||
}
|
||||
|
||||
//
|
||||
// Expose the module.
|
||||
//
|
||||
exports.stringify = querystringify;
|
||||
exports.parse = querystring;
|
||||
|
||||
},{}],3:[function(require,module,exports){
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Check if we're required to add a port number.
|
||||
*
|
||||
* @see https://url.spec.whatwg.org/#default-port
|
||||
* @param {Number|String} port Port number we need to check
|
||||
* @param {String} protocol Protocol we need to check against.
|
||||
* @returns {Boolean} Is it a default port for the given protocol
|
||||
* @api private
|
||||
*/
|
||||
module.exports = function required(port, protocol) {
|
||||
protocol = protocol.split(':')[0];
|
||||
port = +port;
|
||||
|
||||
if (!port) return false;
|
||||
|
||||
switch (protocol) {
|
||||
case 'http':
|
||||
case 'ws':
|
||||
return port !== 80;
|
||||
|
||||
case 'https':
|
||||
case 'wss':
|
||||
return port !== 443;
|
||||
|
||||
case 'ftp':
|
||||
return port !== 21;
|
||||
|
||||
case 'gopher':
|
||||
return port !== 70;
|
||||
|
||||
case 'file':
|
||||
return false;
|
||||
}
|
||||
|
||||
return port !== 0;
|
||||
};
|
||||
|
||||
},{}]},{},[1])(1)
|
||||
});
|
1
node_modules/url-parse/dist/url-parse.min.js
generated
vendored
Normal file
1
node_modules/url-parse/dist/url-parse.min.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).URLParse=e()}}(function(){return function s(a,i,p){function f(t,e){if(!i[t]){if(!a[t]){var o="function"==typeof require&&require;if(!e&&o)return o(t,!0);if(c)return c(t,!0);var r=new Error("Cannot find module '"+t+"'");throw r.code="MODULE_NOT_FOUND",r}var n=i[t]={exports:{}};a[t][0].call(n.exports,function(e){return f(a[t][1][e]||e)},n,n.exports,s,a,i,p)}return i[t].exports}for(var c="function"==typeof require&&require,e=0;e<p.length;e++)f(p[e]);return f}({1:[function(e,t,o){(function(s){"use strict";var h=e("requires-port"),d=e("querystringify"),o=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\S\s]*)/i,a=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,y=[["#","hash"],["?","query"],function(e){return e.replace("\\","/")},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d+)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],i={hash:1,query:1};function m(e){var t,o=("undefined"!=typeof window?window:void 0!==s?s:"undefined"!=typeof self?self:{}).location||{},r={},n=typeof(e=e||o);if("blob:"===e.protocol)r=new g(unescape(e.pathname),{});else if("string"===n)for(t in r=new g(e,{}),i)delete r[t];else if("object"===n){for(t in e)t in i||(r[t]=e[t]);void 0===r.slashes&&(r.slashes=a.test(e.href))}return r}function w(e){var t=o.exec(e);return{protocol:t[1]?t[1].toLowerCase():"",slashes:!!t[2],rest:t[3]}}function g(e,t,o){if(!(this instanceof g))return new g(e,t,o);var r,n,s,a,i,p,f=y.slice(),c=typeof t,u=this,l=0;for("object"!==c&&"string"!==c&&(o=t,t=null),o&&"function"!=typeof o&&(o=d.parse),t=m(t),r=!(n=w(e||"")).protocol&&!n.slashes,u.slashes=n.slashes||r&&t.slashes,u.protocol=n.protocol||t.protocol||"",e=n.rest,n.slashes||(f[3]=[/(.*)/,"pathname"]);l<f.length;l++)"function"!=typeof(a=f[l])?(s=a[0],p=a[1],s!=s?u[p]=e:"string"==typeof s?~(i=e.indexOf(s))&&("number"==typeof a[2]?(u[p]=e.slice(0,i),e=e.slice(i+a[2])):(u[p]=e.slice(i),e=e.slice(0,i))):(i=s.exec(e))&&(u[p]=i[1],e=e.slice(0,i.index)),u[p]=u[p]||r&&a[3]&&t[p]||"",a[4]&&(u[p]=u[p].toLowerCase())):e=a(e);o&&(u.query=o(u.query)),r&&t.slashes&&"/"!==u.pathname.charAt(0)&&(""!==u.pathname||""!==t.pathname)&&(u.pathname=function(e,t){for(var o=(t||"/").split("/").slice(0,-1).concat(e.split("/")),r=o.length,n=o[r-1],s=!1,a=0;r--;)"."===o[r]?o.splice(r,1):".."===o[r]?(o.splice(r,1),a++):a&&(0===r&&(s=!0),o.splice(r,1),a--);return s&&o.unshift(""),"."!==n&&".."!==n||o.push(""),o.join("/")}(u.pathname,t.pathname)),h(u.port,u.protocol)||(u.host=u.hostname,u.port=""),u.username=u.password="",u.auth&&(a=u.auth.split(":"),u.username=a[0]||"",u.password=a[1]||""),u.origin=u.protocol&&u.host&&"file:"!==u.protocol?u.protocol+"//"+u.host:"null",u.href=u.toString()}g.prototype={set:function(e,t,o){var r=this;switch(e){case"query":"string"==typeof t&&t.length&&(t=(o||d.parse)(t)),r[e]=t;break;case"port":r[e]=t,h(t,r.protocol)?t&&(r.host=r.hostname+":"+t):(r.host=r.hostname,r[e]="");break;case"hostname":r[e]=t,r.port&&(t+=":"+r.port),r.host=t;break;case"host":r[e]=t,/:\d+$/.test(t)?(t=t.split(":"),r.port=t.pop(),r.hostname=t.join(":")):(r.hostname=t,r.port="");break;case"protocol":r.protocol=t.toLowerCase(),r.slashes=!o;break;case"pathname":case"hash":if(t){var n="pathname"===e?"/":"#";r[e]=t.charAt(0)!==n?n+t:t}else r[e]=t;break;default:r[e]=t}for(var s=0;s<y.length;s++){var a=y[s];a[4]&&(r[a[1]]=r[a[1]].toLowerCase())}return r.origin=r.protocol&&r.host&&"file:"!==r.protocol?r.protocol+"//"+r.host:"null",r.href=r.toString(),r},toString:function(e){e&&"function"==typeof e||(e=d.stringify);var t,o=this,r=o.protocol;r&&":"!==r.charAt(r.length-1)&&(r+=":");var n=r+(o.slashes?"//":"");return o.username&&(n+=o.username,o.password&&(n+=":"+o.password),n+="@"),n+=o.host+o.pathname,(t="object"==typeof o.query?e(o.query):o.query)&&(n+="?"!==t.charAt(0)?"?"+t:t),o.hash&&(n+=o.hash),n}},g.extractProtocol=w,g.location=m,g.qs=d,t.exports=g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{querystringify:2,"requires-port":3}],2:[function(e,t,o){"use strict";var n=Object.prototype.hasOwnProperty;function a(e){return decodeURIComponent(e.replace(/\+/g," "))}o.stringify=function(e,t){t=t||"";var o=[];for(var r in"string"!=typeof t&&(t="?"),e)n.call(e,r)&&o.push(encodeURIComponent(r)+"="+encodeURIComponent(e[r]));return o.length?t+o.join("&"):""},o.parse=function(e){for(var t,o=/([^=?&]+)=?([^&]*)/g,r={};t=o.exec(e);){var n=a(t[1]),s=a(t[2]);n in r||(r[n]=s)}return r}},{}],3:[function(e,t,o){"use strict";t.exports=function(e,t){if(t=t.split(":")[0],!(e=+e))return!1;switch(t){case"http":case"ws":return 80!==e;case"https":case"wss":return 443!==e;case"ftp":return 21!==e;case"gopher":return 70!==e;case"file":return!1}return 0!==e}},{}]},{},[1])(1)});
|
1
node_modules/url-parse/dist/url-parse.min.js.map
generated
vendored
Normal file
1
node_modules/url-parse/dist/url-parse.min.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
432
node_modules/url-parse/index.js
generated
vendored
Normal file
432
node_modules/url-parse/index.js
generated
vendored
Normal file
@ -0,0 +1,432 @@
|
||||
'use strict';
|
||||
|
||||
var required = require('requires-port')
|
||||
, qs = require('querystringify')
|
||||
, protocolre = /^([a-z][a-z0-9.+-]*:)?(\/\/)?([\S\s]*)/i
|
||||
, slashes = /^[A-Za-z][A-Za-z0-9+-.]*:\/\//;
|
||||
|
||||
/**
|
||||
* These are the parse rules for the URL parser, it informs the parser
|
||||
* about:
|
||||
*
|
||||
* 0. The char it Needs to parse, if it's a string it should be done using
|
||||
* indexOf, RegExp using exec and NaN means set as current value.
|
||||
* 1. The property we should set when parsing this value.
|
||||
* 2. Indication if it's backwards or forward parsing, when set as number it's
|
||||
* the value of extra chars that should be split off.
|
||||
* 3. Inherit from location if non existing in the parser.
|
||||
* 4. `toLowerCase` the resulting value.
|
||||
*/
|
||||
var rules = [
|
||||
['#', 'hash'], // Extract from the back.
|
||||
['?', 'query'], // Extract from the back.
|
||||
function sanitize(address) { // Sanitize what is left of the address
|
||||
return address.replace('\\', '/');
|
||||
},
|
||||
['/', 'pathname'], // Extract from the back.
|
||||
['@', 'auth', 1], // Extract from the front.
|
||||
[NaN, 'host', undefined, 1, 1], // Set left over value.
|
||||
[/:(\d+)$/, 'port', undefined, 1], // RegExp the back.
|
||||
[NaN, 'hostname', undefined, 1, 1] // Set left over.
|
||||
];
|
||||
|
||||
/**
|
||||
* These properties should not be copied or inherited from. This is only needed
|
||||
* for all non blob URL's as a blob URL does not include a hash, only the
|
||||
* origin.
|
||||
*
|
||||
* @type {Object}
|
||||
* @private
|
||||
*/
|
||||
var ignore = { hash: 1, query: 1 };
|
||||
|
||||
/**
|
||||
* The location object differs when your code is loaded through a normal page,
|
||||
* Worker or through a worker using a blob. And with the blobble begins the
|
||||
* trouble as the location object will contain the URL of the blob, not the
|
||||
* location of the page where our code is loaded in. The actual origin is
|
||||
* encoded in the `pathname` so we can thankfully generate a good "default"
|
||||
* location from it so we can generate proper relative URL's again.
|
||||
*
|
||||
* @param {Object|String} loc Optional default location object.
|
||||
* @returns {Object} lolcation object.
|
||||
* @public
|
||||
*/
|
||||
function lolcation(loc) {
|
||||
var globalVar;
|
||||
|
||||
if (typeof window !== 'undefined') globalVar = window;
|
||||
else if (typeof global !== 'undefined') globalVar = global;
|
||||
else if (typeof self !== 'undefined') globalVar = self;
|
||||
else globalVar = {};
|
||||
|
||||
var location = globalVar.location || {};
|
||||
loc = loc || location;
|
||||
|
||||
var finaldestination = {}
|
||||
, type = typeof loc
|
||||
, key;
|
||||
|
||||
if ('blob:' === loc.protocol) {
|
||||
finaldestination = new Url(unescape(loc.pathname), {});
|
||||
} else if ('string' === type) {
|
||||
finaldestination = new Url(loc, {});
|
||||
for (key in ignore) delete finaldestination[key];
|
||||
} else if ('object' === type) {
|
||||
for (key in loc) {
|
||||
if (key in ignore) continue;
|
||||
finaldestination[key] = loc[key];
|
||||
}
|
||||
|
||||
if (finaldestination.slashes === undefined) {
|
||||
finaldestination.slashes = slashes.test(loc.href);
|
||||
}
|
||||
}
|
||||
|
||||
return finaldestination;
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef ProtocolExtract
|
||||
* @type Object
|
||||
* @property {String} protocol Protocol matched in the URL, in lowercase.
|
||||
* @property {Boolean} slashes `true` if protocol is followed by "//", else `false`.
|
||||
* @property {String} rest Rest of the URL that is not part of the protocol.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Extract protocol information from a URL with/without double slash ("//").
|
||||
*
|
||||
* @param {String} address URL we want to extract from.
|
||||
* @return {ProtocolExtract} Extracted information.
|
||||
* @private
|
||||
*/
|
||||
function extractProtocol(address) {
|
||||
var match = protocolre.exec(address);
|
||||
|
||||
return {
|
||||
protocol: match[1] ? match[1].toLowerCase() : '',
|
||||
slashes: !!match[2],
|
||||
rest: match[3]
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a relative URL pathname against a base URL pathname.
|
||||
*
|
||||
* @param {String} relative Pathname of the relative URL.
|
||||
* @param {String} base Pathname of the base URL.
|
||||
* @return {String} Resolved pathname.
|
||||
* @private
|
||||
*/
|
||||
function resolve(relative, base) {
|
||||
var path = (base || '/').split('/').slice(0, -1).concat(relative.split('/'))
|
||||
, i = path.length
|
||||
, last = path[i - 1]
|
||||
, unshift = false
|
||||
, up = 0;
|
||||
|
||||
while (i--) {
|
||||
if (path[i] === '.') {
|
||||
path.splice(i, 1);
|
||||
} else if (path[i] === '..') {
|
||||
path.splice(i, 1);
|
||||
up++;
|
||||
} else if (up) {
|
||||
if (i === 0) unshift = true;
|
||||
path.splice(i, 1);
|
||||
up--;
|
||||
}
|
||||
}
|
||||
|
||||
if (unshift) path.unshift('');
|
||||
if (last === '.' || last === '..') path.push('');
|
||||
|
||||
return path.join('/');
|
||||
}
|
||||
|
||||
/**
|
||||
* The actual URL instance. Instead of returning an object we've opted-in to
|
||||
* create an actual constructor as it's much more memory efficient and
|
||||
* faster and it pleases my OCD.
|
||||
*
|
||||
* It is worth noting that we should not use `URL` as class name to prevent
|
||||
* clashes with the global URL instance that got introduced in browsers.
|
||||
*
|
||||
* @constructor
|
||||
* @param {String} address URL we want to parse.
|
||||
* @param {Object|String} [location] Location defaults for relative paths.
|
||||
* @param {Boolean|Function} [parser] Parser for the query string.
|
||||
* @private
|
||||
*/
|
||||
function Url(address, location, parser) {
|
||||
if (!(this instanceof Url)) {
|
||||
return new Url(address, location, parser);
|
||||
}
|
||||
|
||||
var relative, extracted, parse, instruction, index, key
|
||||
, instructions = rules.slice()
|
||||
, type = typeof location
|
||||
, url = this
|
||||
, i = 0;
|
||||
|
||||
//
|
||||
// The following if statements allows this module two have compatibility with
|
||||
// 2 different API:
|
||||
//
|
||||
// 1. Node.js's `url.parse` api which accepts a URL, boolean as arguments
|
||||
// where the boolean indicates that the query string should also be parsed.
|
||||
//
|
||||
// 2. The `URL` interface of the browser which accepts a URL, object as
|
||||
// arguments. The supplied object will be used as default values / fall-back
|
||||
// for relative paths.
|
||||
//
|
||||
if ('object' !== type && 'string' !== type) {
|
||||
parser = location;
|
||||
location = null;
|
||||
}
|
||||
|
||||
if (parser && 'function' !== typeof parser) parser = qs.parse;
|
||||
|
||||
location = lolcation(location);
|
||||
|
||||
//
|
||||
// Extract protocol information before running the instructions.
|
||||
//
|
||||
extracted = extractProtocol(address || '');
|
||||
relative = !extracted.protocol && !extracted.slashes;
|
||||
url.slashes = extracted.slashes || relative && location.slashes;
|
||||
url.protocol = extracted.protocol || location.protocol || '';
|
||||
address = extracted.rest;
|
||||
|
||||
//
|
||||
// When the authority component is absent the URL starts with a path
|
||||
// component.
|
||||
//
|
||||
if (!extracted.slashes) instructions[3] = [/(.*)/, 'pathname'];
|
||||
|
||||
for (; i < instructions.length; i++) {
|
||||
instruction = instructions[i];
|
||||
|
||||
if (typeof instruction === 'function') {
|
||||
address = instruction(address);
|
||||
continue;
|
||||
}
|
||||
|
||||
parse = instruction[0];
|
||||
key = instruction[1];
|
||||
|
||||
if (parse !== parse) {
|
||||
url[key] = address;
|
||||
} else if ('string' === typeof parse) {
|
||||
if (~(index = address.indexOf(parse))) {
|
||||
if ('number' === typeof instruction[2]) {
|
||||
url[key] = address.slice(0, index);
|
||||
address = address.slice(index + instruction[2]);
|
||||
} else {
|
||||
url[key] = address.slice(index);
|
||||
address = address.slice(0, index);
|
||||
}
|
||||
}
|
||||
} else if ((index = parse.exec(address))) {
|
||||
url[key] = index[1];
|
||||
address = address.slice(0, index.index);
|
||||
}
|
||||
|
||||
url[key] = url[key] || (
|
||||
relative && instruction[3] ? location[key] || '' : ''
|
||||
);
|
||||
|
||||
//
|
||||
// Hostname, host and protocol should be lowercased so they can be used to
|
||||
// create a proper `origin`.
|
||||
//
|
||||
if (instruction[4]) url[key] = url[key].toLowerCase();
|
||||
}
|
||||
|
||||
//
|
||||
// Also parse the supplied query string in to an object. If we're supplied
|
||||
// with a custom parser as function use that instead of the default build-in
|
||||
// parser.
|
||||
//
|
||||
if (parser) url.query = parser(url.query);
|
||||
|
||||
//
|
||||
// If the URL is relative, resolve the pathname against the base URL.
|
||||
//
|
||||
if (
|
||||
relative
|
||||
&& location.slashes
|
||||
&& url.pathname.charAt(0) !== '/'
|
||||
&& (url.pathname !== '' || location.pathname !== '')
|
||||
) {
|
||||
url.pathname = resolve(url.pathname, location.pathname);
|
||||
}
|
||||
|
||||
//
|
||||
// We should not add port numbers if they are already the default port number
|
||||
// for a given protocol. As the host also contains the port number we're going
|
||||
// override it with the hostname which contains no port number.
|
||||
//
|
||||
if (!required(url.port, url.protocol)) {
|
||||
url.host = url.hostname;
|
||||
url.port = '';
|
||||
}
|
||||
|
||||
//
|
||||
// Parse down the `auth` for the username and password.
|
||||
//
|
||||
url.username = url.password = '';
|
||||
if (url.auth) {
|
||||
instruction = url.auth.split(':');
|
||||
url.username = instruction[0] || '';
|
||||
url.password = instruction[1] || '';
|
||||
}
|
||||
|
||||
url.origin = url.protocol && url.host && url.protocol !== 'file:'
|
||||
? url.protocol +'//'+ url.host
|
||||
: 'null';
|
||||
|
||||
//
|
||||
// The href is just the compiled result.
|
||||
//
|
||||
url.href = url.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* This is convenience method for changing properties in the URL instance to
|
||||
* insure that they all propagate correctly.
|
||||
*
|
||||
* @param {String} part Property we need to adjust.
|
||||
* @param {Mixed} value The newly assigned value.
|
||||
* @param {Boolean|Function} fn When setting the query, it will be the function
|
||||
* used to parse the query.
|
||||
* When setting the protocol, double slash will be
|
||||
* removed from the final url if it is true.
|
||||
* @returns {URL} URL instance for chaining.
|
||||
* @public
|
||||
*/
|
||||
function set(part, value, fn) {
|
||||
var url = this;
|
||||
|
||||
switch (part) {
|
||||
case 'query':
|
||||
if ('string' === typeof value && value.length) {
|
||||
value = (fn || qs.parse)(value);
|
||||
}
|
||||
|
||||
url[part] = value;
|
||||
break;
|
||||
|
||||
case 'port':
|
||||
url[part] = value;
|
||||
|
||||
if (!required(value, url.protocol)) {
|
||||
url.host = url.hostname;
|
||||
url[part] = '';
|
||||
} else if (value) {
|
||||
url.host = url.hostname +':'+ value;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'hostname':
|
||||
url[part] = value;
|
||||
|
||||
if (url.port) value += ':'+ url.port;
|
||||
url.host = value;
|
||||
break;
|
||||
|
||||
case 'host':
|
||||
url[part] = value;
|
||||
|
||||
if (/:\d+$/.test(value)) {
|
||||
value = value.split(':');
|
||||
url.port = value.pop();
|
||||
url.hostname = value.join(':');
|
||||
} else {
|
||||
url.hostname = value;
|
||||
url.port = '';
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'protocol':
|
||||
url.protocol = value.toLowerCase();
|
||||
url.slashes = !fn;
|
||||
break;
|
||||
|
||||
case 'pathname':
|
||||
case 'hash':
|
||||
if (value) {
|
||||
var char = part === 'pathname' ? '/' : '#';
|
||||
url[part] = value.charAt(0) !== char ? char + value : value;
|
||||
} else {
|
||||
url[part] = value;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
url[part] = value;
|
||||
}
|
||||
|
||||
for (var i = 0; i < rules.length; i++) {
|
||||
var ins = rules[i];
|
||||
|
||||
if (ins[4]) url[ins[1]] = url[ins[1]].toLowerCase();
|
||||
}
|
||||
|
||||
url.origin = url.protocol && url.host && url.protocol !== 'file:'
|
||||
? url.protocol +'//'+ url.host
|
||||
: 'null';
|
||||
|
||||
url.href = url.toString();
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform the properties back in to a valid and full URL string.
|
||||
*
|
||||
* @param {Function} stringify Optional query stringify function.
|
||||
* @returns {String} Compiled version of the URL.
|
||||
* @public
|
||||
*/
|
||||
function toString(stringify) {
|
||||
if (!stringify || 'function' !== typeof stringify) stringify = qs.stringify;
|
||||
|
||||
var query
|
||||
, url = this
|
||||
, protocol = url.protocol;
|
||||
|
||||
if (protocol && protocol.charAt(protocol.length - 1) !== ':') protocol += ':';
|
||||
|
||||
var result = protocol + (url.slashes ? '//' : '');
|
||||
|
||||
if (url.username) {
|
||||
result += url.username;
|
||||
if (url.password) result += ':'+ url.password;
|
||||
result += '@';
|
||||
}
|
||||
|
||||
result += url.host + url.pathname;
|
||||
|
||||
query = 'object' === typeof url.query ? stringify(url.query) : url.query;
|
||||
if (query) result += '?' !== query.charAt(0) ? '?'+ query : query;
|
||||
|
||||
if (url.hash) result += url.hash;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Url.prototype = { set: set, toString: toString };
|
||||
|
||||
//
|
||||
// Expose the URL parser and some additional properties that might be useful for
|
||||
// others or testing.
|
||||
//
|
||||
Url.extractProtocol = extractProtocol;
|
||||
Url.location = lolcation;
|
||||
Url.qs = qs;
|
||||
|
||||
module.exports = Url;
|
80
node_modules/url-parse/package.json
generated
vendored
Normal file
80
node_modules/url-parse/package.json
generated
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
{
|
||||
"_from": "url-parse@^1.2.0",
|
||||
"_id": "url-parse@1.4.4",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-/92DTTorg4JjktLNLe6GPS2/RvAd/RGr6LuktmWSMLEOa6rjnlrFXNgSbSmkNvCoL2T028A0a1JaJLzRMlFoHg==",
|
||||
"_location": "/url-parse",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "url-parse@^1.2.0",
|
||||
"name": "url-parse",
|
||||
"escapedName": "url-parse",
|
||||
"rawSpec": "^1.2.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.2.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/mock-socket"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.4.tgz",
|
||||
"_shasum": "cac1556e95faa0303691fec5cf9d5a1bc34648f8",
|
||||
"_spec": "url-parse@^1.2.0",
|
||||
"_where": "/Users/josh.burman/Projects/braid/node_modules/mock-socket",
|
||||
"author": {
|
||||
"name": "Arnout Kazemier"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/unshiftio/url-parse/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"querystringify": "^2.0.0",
|
||||
"requires-port": "^1.0.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Small footprint URL parser that works seamlessly across Node.js and browser environments",
|
||||
"devDependencies": {
|
||||
"assume": "^1.5.2",
|
||||
"browserify": "^16.2.0",
|
||||
"mocha": "^5.1.1",
|
||||
"nyc": "^12.0.1",
|
||||
"pre-commit": "^1.2.0",
|
||||
"sauce-browsers": "^2.0.0",
|
||||
"sauce-test": "^1.3.3",
|
||||
"uglify-js": "^3.3.21"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"dist"
|
||||
],
|
||||
"homepage": "https://github.com/unshiftio/url-parse#readme",
|
||||
"keywords": [
|
||||
"URL",
|
||||
"parser",
|
||||
"uri",
|
||||
"url",
|
||||
"parse",
|
||||
"query",
|
||||
"string",
|
||||
"querystring",
|
||||
"stringify"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "url-parse",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/unshiftio/url-parse.git"
|
||||
},
|
||||
"scripts": {
|
||||
"browserify": "rm -rf dist && mkdir -p dist && browserify index.js -s URLParse -o dist/url-parse.js",
|
||||
"minify": "uglifyjs dist/url-parse.js --source-map -cm -o dist/url-parse.min.js",
|
||||
"prepublishOnly": "npm run browserify && npm run minify",
|
||||
"test": "nyc --reporter=html --reporter=text mocha test/test.js",
|
||||
"test-browser": "node test/browser.js",
|
||||
"watch": "mocha --watch test/test.js"
|
||||
},
|
||||
"version": "1.4.4"
|
||||
}
|
Reference in New Issue
Block a user