fix
This commit is contained in:
21
book/node_modules/urijs/LICENSE.txt
generated
vendored
Normal file
21
book/node_modules/urijs/LICENSE.txt
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2011 Rodney Rehm
|
||||
|
||||
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.
|
||||
249
book/node_modules/urijs/README.md
generated
vendored
Normal file
249
book/node_modules/urijs/README.md
generated
vendored
Normal file
@@ -0,0 +1,249 @@
|
||||
# URI.js #
|
||||
|
||||
[](https://cdnjs.com/libraries/URI.js)
|
||||
* [About](http://medialize.github.io/URI.js/)
|
||||
* [Understanding URIs](http://medialize.github.io/URI.js/about-uris.html)
|
||||
* [Documentation](http://medialize.github.io/URI.js/docs.html)
|
||||
* [jQuery URI Plugin](http://medialize.github.io/URI.js/jquery-uri-plugin.html)
|
||||
* [Author](http://rodneyrehm.de/en/)
|
||||
* [Changelog](./CHANGELOG.md)
|
||||
|
||||
---
|
||||
|
||||
> **IMPORTANT:** You **may not need URI.js** anymore! Modern browsers provide the [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL) and [URLSearchParams](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) interfaces.
|
||||
|
||||
---
|
||||
|
||||
> **NOTE:** The npm package name changed to `urijs`
|
||||
|
||||
---
|
||||
|
||||
I always want to shoot myself in the head when looking at code like the following:
|
||||
|
||||
```javascript
|
||||
var url = "http://example.org/foo?bar=baz";
|
||||
var separator = url.indexOf('?') > -1 ? '&' : '?';
|
||||
|
||||
url += separator + encodeURIComponent("foo") + "=" + encodeURIComponent("bar");
|
||||
```
|
||||
|
||||
Things are looking up with [URL](https://developer.mozilla.org/en/docs/Web/API/URL) and the [URL spec](http://url.spec.whatwg.org/) but until we can safely rely on that API, have a look at URI.js for a clean and simple API for mutating URIs:
|
||||
|
||||
```javascript
|
||||
var url = new URI("http://example.org/foo?bar=baz");
|
||||
url.addQuery("foo", "bar");
|
||||
```
|
||||
|
||||
URI.js is here to help with that.
|
||||
|
||||
|
||||
## API Example ##
|
||||
|
||||
```javascript
|
||||
// mutating URLs
|
||||
URI("http://example.org/foo.html?hello=world")
|
||||
.username("rodneyrehm")
|
||||
// -> http://rodneyrehm@example.org/foo.html?hello=world
|
||||
.username("")
|
||||
// -> http://example.org/foo.html?hello=world
|
||||
.directory("bar")
|
||||
// -> http://example.org/bar/foo.html?hello=world
|
||||
.suffix("xml")
|
||||
// -> http://example.org/bar/foo.xml?hello=world
|
||||
.query("")
|
||||
// -> http://example.org/bar/foo.xml
|
||||
.tld("com")
|
||||
// -> http://example.com/bar/foo.xml
|
||||
.query({ foo: "bar", hello: ["world", "mars"] });
|
||||
// -> http://example.com/bar/foo.xml?foo=bar&hello=world&hello=mars
|
||||
|
||||
// cleaning things up
|
||||
URI("?&foo=bar&&foo=bar&foo=baz&")
|
||||
.normalizeQuery();
|
||||
// -> ?foo=bar&foo=baz
|
||||
|
||||
// working with relative paths
|
||||
URI("/foo/bar/baz.html")
|
||||
.relativeTo("/foo/bar/world.html");
|
||||
// -> ./baz.html
|
||||
|
||||
URI("/foo/bar/baz.html")
|
||||
.relativeTo("/foo/bar/sub/world.html")
|
||||
// -> ../baz.html
|
||||
.absoluteTo("/foo/bar/sub/world.html");
|
||||
// -> /foo/bar/baz.html
|
||||
|
||||
// URI Templates
|
||||
URI.expand("/foo/{dir}/{file}", {
|
||||
dir: "bar",
|
||||
file: "world.html"
|
||||
});
|
||||
// -> /foo/bar/world.html
|
||||
```
|
||||
|
||||
See the [About Page](http://medialize.github.io/URI.js/) and [API Docs](http://medialize.github.io/URI.js/docs.html) for more stuff.
|
||||
|
||||
## Using URI.js ##
|
||||
|
||||
URI.js (without plugins) has a gzipped weight of about 7KB - if you include all extensions you end up at about 13KB. So unless you *need* second level domain support and use URI templates, we suggest you don't include them in your build. If you don't need a full featured URI mangler, it may be worth looking into the much smaller parser-only alternatives [listed below](#alternatives).
|
||||
|
||||
URI.js is available through [npm](https://www.npmjs.com/package/urijs), [bower](http://bower.io/search/?q=urijs), [bowercdn](http://bowercdn.net/package/urijs), [cdnjs](https://cdnjs.com/libraries/URI.js) and manually from the [build page](http://medialize.github.io/URI.js/build.html):
|
||||
|
||||
```bash
|
||||
# using bower
|
||||
bower install uri.js
|
||||
|
||||
# using npm
|
||||
npm install urijs
|
||||
```
|
||||
|
||||
### Browser ###
|
||||
|
||||
I guess you'll manage to use the [build tool](http://medialize.github.io/URI.js/build.html) or follow the [instructions below](#minify) to combine and minify the various files into URI.min.js - and I'm fairly certain you know how to `<script src=".../URI.min.js"></script>` that sucker, too.
|
||||
|
||||
### Node.js and NPM ###
|
||||
|
||||
Install with `npm install urijs` or add `"urijs"` to the dependencies in your `package.json`.
|
||||
|
||||
```javascript
|
||||
// load URI.js
|
||||
var URI = require('urijs');
|
||||
// load an optional module (e.g. URITemplate)
|
||||
var URITemplate = require('urijs/src/URITemplate');
|
||||
|
||||
URI("/foo/bar/baz.html")
|
||||
.relativeTo("/foo/bar/sub/world.html")
|
||||
// -> ../baz.html
|
||||
```
|
||||
|
||||
### RequireJS ###
|
||||
|
||||
Clone the URI.js repository or use a package manager to get URI.js into your project.
|
||||
|
||||
```javascript
|
||||
require.config({
|
||||
paths: {
|
||||
urijs: 'where-you-put-uri.js/src'
|
||||
}
|
||||
});
|
||||
|
||||
require(['urijs/URI'], function(URI) {
|
||||
console.log("URI.js and dependencies: ", URI("//amazon.co.uk").is('sld') ? 'loaded' : 'failed');
|
||||
});
|
||||
require(['urijs/URITemplate'], function(URITemplate) {
|
||||
console.log("URITemplate.js and dependencies: ", URITemplate._cache ? 'loaded' : 'failed');
|
||||
});
|
||||
```
|
||||
|
||||
## Minify ##
|
||||
|
||||
See the [build tool](http://medialize.github.io/URI.js/build.html) or use [Google Closure Compiler](http://closure-compiler.appspot.com/home):
|
||||
|
||||
```
|
||||
// ==ClosureCompiler==
|
||||
// @compilation_level SIMPLE_OPTIMIZATIONS
|
||||
// @output_file_name URI.min.js
|
||||
// @code_url http://medialize.github.io/URI.js/src/IPv6.js
|
||||
// @code_url http://medialize.github.io/URI.js/src/punycode.js
|
||||
// @code_url http://medialize.github.io/URI.js/src/SecondLevelDomains.js
|
||||
// @code_url http://medialize.github.io/URI.js/src/URI.js
|
||||
// @code_url http://medialize.github.io/URI.js/src/URITemplate.js
|
||||
// ==/ClosureCompiler==
|
||||
```
|
||||
|
||||
|
||||
## Resources ##
|
||||
|
||||
Documents specifying how URLs work:
|
||||
|
||||
* [URL - Living Standard](http://url.spec.whatwg.org/)
|
||||
* [RFC 3986 - Uniform Resource Identifier (URI): Generic Syntax](http://tools.ietf.org/html/rfc3986)
|
||||
* [RFC 3987 - Internationalized Resource Identifiers (IRI)](http://tools.ietf.org/html/rfc3987)
|
||||
* [RFC 2732 - Format for Literal IPv6 Addresses in URL's](http://tools.ietf.org/html/rfc2732)
|
||||
* [RFC 2368 - The `mailto:` URL Scheme](https://www.ietf.org/rfc/rfc2368.txt)
|
||||
* [RFC 2141 - URN Syntax](https://www.ietf.org/rfc/rfc2141.txt)
|
||||
* [IANA URN Namespace Registry](http://www.iana.org/assignments/urn-namespaces/urn-namespaces.xhtml)
|
||||
* [Punycode: A Bootstring encoding of Unicode for Internationalized Domain Names in Applications (IDNA)](http://tools.ietf.org/html/rfc3492)
|
||||
* [application/x-www-form-urlencoded](http://www.w3.org/TR/REC-html40/interact/forms.html#form-content-type) (Query String Parameters) and [application/x-www-form-urlencoded encoding algorithm](http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#application/x-www-form-urlencoded-encoding-algorithm)
|
||||
* [What every web developer must know about URL encoding](http://blog.lunatech.com/2009/02/03/what-every-web-developer-must-know-about-url-encoding)
|
||||
|
||||
Informal stuff
|
||||
|
||||
* [Parsing URLs for Fun and Profit](http://tools.ietf.org/html/draft-abarth-url-01)
|
||||
* [Naming URL components](http://tantek.com/2011/238/b1/many-ways-slice-url-name-pieces)
|
||||
|
||||
How other environments do things
|
||||
|
||||
* [Java URI Class](http://docs.oracle.com/javase/7/docs/api/java/net/URI.html)
|
||||
* [Java Inet6Address Class](http://docs.oracle.com/javase/1.5.0/docs/api/java/net/Inet6Address.html)
|
||||
* [Node.js URL API](http://nodejs.org/docs/latest/api/url.html)
|
||||
|
||||
[Discussion on Hacker News](https://news.ycombinator.com/item?id=3398837)
|
||||
|
||||
### Forks / Code-borrow ###
|
||||
|
||||
* [node-dom-urls](https://github.com/passy/node-dom-urls) passy's partial implementation of the W3C URL Spec Draft for Node
|
||||
* [urlutils](https://github.com/cofounders/urlutils) cofounders' `window.URL` constructor for Node
|
||||
|
||||
### Alternatives ###
|
||||
|
||||
If you don't like URI.js, you may like one of the following libraries. (If yours is not listed, drop me a line…)
|
||||
|
||||
#### Polyfill ####
|
||||
|
||||
* [DOM-URL-Polyfill](https://github.com/arv/DOM-URL-Polyfill/) arv's polyfill of the [DOM URL spec](https://dvcs.w3.org/hg/url/raw-file/tip/Overview.html#interface-urlutils) for browsers
|
||||
* [inexorabletash](https://github.com/inexorabletash/polyfill/#whatwg-url-api) inexorabletash's [WHATWG URL API](http://url.spec.whatwg.org/)
|
||||
|
||||
#### URL Manipulation ####
|
||||
|
||||
* [The simple <a> URL Mutation "Hack"](http://jsfiddle.net/rodneyrehm/KkGUJ/) ([jsPerf comparison](http://jsperf.com/idl-attributes-vs-uri-js))
|
||||
* [URL.js](https://github.com/ericf/urljs)
|
||||
* [furl (Python)](https://github.com/gruns/furl)
|
||||
* [mediawiki Uri](https://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/resources/mediawiki/mediawiki.Uri.js?view=markup) (needs mw and jQuery)
|
||||
* [jurlp](https://github.com/tombonner/jurlp)
|
||||
* [jsUri](https://github.com/derek-watson/jsUri)
|
||||
|
||||
#### URL Parsers ####
|
||||
|
||||
* [The simple <a> URL Mutation "Hack"](http://jsfiddle.net/rodneyrehm/KkGUJ/) ([jsPerf comparison](http://jsperf.com/idl-attributes-vs-uri-js))
|
||||
* [URI Parser](http://blog.stevenlevithan.com/archives/parseuri)
|
||||
* [jQuery-URL-Parser](https://github.com/allmarkedup/jQuery-URL-Parser)
|
||||
* [Google Closure Uri](https://google.github.io/closure-library/api/class_goog_Uri.html)
|
||||
* [URI.js by Gary Court](https://github.com/garycourt/uri-js)
|
||||
|
||||
#### URI Template ####
|
||||
|
||||
* [uri-template](https://github.com/rezigned/uri-template.js) (supporting extraction as well) by Rezigne
|
||||
* [uri-templates](https://github.com/geraintluff/uri-templates) (supporting extraction as well) by Geraint Luff
|
||||
* [uri-templates](https://github.com/marc-portier/uri-templates) by Marc Portier
|
||||
* [uri-templates](https://github.com/geraintluff/uri-templates) by Geraint Luff (including reverse operation)
|
||||
* [URI Template JS](https://github.com/fxa/uritemplate-js) by Franz Antesberger
|
||||
* [Temple](https://github.com/brettstimmerman/temple) by Brett Stimmerman
|
||||
* ([jsperf comparison](http://jsperf.com/uri-templates/2))
|
||||
|
||||
#### Various ####
|
||||
|
||||
* [TLD.js](https://github.com/oncletom/tld.js) - second level domain names
|
||||
* [Public Suffix](http://mxr.mozilla.org/mozilla-central/source/netwerk/dns/effective_tld_names.dat?raw=1) - second level domain names
|
||||
* [uri-collection](https://github.com/scivey/uri-collection) - underscore based utility for working with many URIs
|
||||
|
||||
## Authors ##
|
||||
|
||||
* [Rodney Rehm](https://github.com/rodneyrehm)
|
||||
* [Various Contributors](https://github.com/medialize/URI.js/graphs/contributors)
|
||||
|
||||
|
||||
## Contains Code From ##
|
||||
|
||||
* [punycode.js](http://mths.be/punycode) - Mathias Bynens
|
||||
* [IPv6.js](http://intermapper.com/support/tools/IPV6-Validator.aspx) - Rich Brown - (rewrite of the original)
|
||||
|
||||
|
||||
## License ##
|
||||
|
||||
URI.js is published under the [MIT license](http://www.opensource.org/licenses/mit-license). Until version 1.13.2 URI.js was also published under the [GPL v3](http://opensource.org/licenses/GPL-3.0) license - but as this dual-licensing causes more questions than helps anyone, it was dropped with version 1.14.0.
|
||||
|
||||
|
||||
## Changelog ##
|
||||
|
||||
moved to [Changelog](./CHANGELOG.md)
|
||||
73
book/node_modules/urijs/package.json
generated
vendored
Normal file
73
book/node_modules/urijs/package.json
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
{
|
||||
"name": "urijs",
|
||||
"version": "1.19.11",
|
||||
"title": "URI.js - Mutating URLs",
|
||||
"author": {
|
||||
"name": "Rodney Rehm",
|
||||
"url": "http://rodneyrehm.de"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/medialize/URI.js.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"description": "URI.js is a Javascript library for working with URLs.",
|
||||
"keywords": [
|
||||
"uri",
|
||||
"url",
|
||||
"urn",
|
||||
"uri mutation",
|
||||
"url mutation",
|
||||
"uri manipulation",
|
||||
"url manipulation",
|
||||
"uri template",
|
||||
"url template",
|
||||
"unified resource locator",
|
||||
"unified resource identifier",
|
||||
"query string",
|
||||
"RFC 3986",
|
||||
"RFC3986",
|
||||
"RFC 6570",
|
||||
"RFC6570",
|
||||
"jquery-plugin",
|
||||
"ecosystem:jquery"
|
||||
],
|
||||
"categories": [
|
||||
"Parsers & Compilers",
|
||||
"Utilities"
|
||||
],
|
||||
"main": "./src/URI",
|
||||
"homepage": "http://medialize.github.io/URI.js/",
|
||||
"contributors": [
|
||||
"Francois-Guillaume Ribreau <npm@fgribreau.com> (http://fgribreau.com)",
|
||||
"Justin Chase <justin.m.chase@gmail.com> (http://justinmchase.com)"
|
||||
],
|
||||
"files": [
|
||||
"src/URI.js",
|
||||
"src/IPv6.js",
|
||||
"src/SecondLevelDomains.js",
|
||||
"src/punycode.js",
|
||||
"src/URITemplate.js",
|
||||
"src/jquery.URI.js",
|
||||
"src/URI.min.js",
|
||||
"src/jquery.URI.min.js",
|
||||
"src/URI.fragmentQuery.js",
|
||||
"src/URI.fragmentURI.js",
|
||||
"LICENSE.txt"
|
||||
],
|
||||
"npmName": "urijs",
|
||||
"npmFileMap": [
|
||||
{
|
||||
"basePath": "/src/",
|
||||
"files": [
|
||||
"*.js"
|
||||
]
|
||||
},
|
||||
{
|
||||
"basePath": "/",
|
||||
"files": [
|
||||
"LICENSE.txt"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
185
book/node_modules/urijs/src/IPv6.js
generated
vendored
Normal file
185
book/node_modules/urijs/src/IPv6.js
generated
vendored
Normal file
@@ -0,0 +1,185 @@
|
||||
/*!
|
||||
* URI.js - Mutating URLs
|
||||
* IPv6 Support
|
||||
*
|
||||
* Version: 1.19.11
|
||||
*
|
||||
* Author: Rodney Rehm
|
||||
* Web: http://medialize.github.io/URI.js/
|
||||
*
|
||||
* Licensed under
|
||||
* MIT License http://www.opensource.org/licenses/mit-license
|
||||
*
|
||||
*/
|
||||
|
||||
(function (root, factory) {
|
||||
'use strict';
|
||||
// https://github.com/umdjs/umd/blob/master/returnExports.js
|
||||
if (typeof module === 'object' && module.exports) {
|
||||
// Node
|
||||
module.exports = factory();
|
||||
} else if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define(factory);
|
||||
} else {
|
||||
// Browser globals (root is window)
|
||||
root.IPv6 = factory(root);
|
||||
}
|
||||
}(this, function (root) {
|
||||
'use strict';
|
||||
|
||||
/*
|
||||
var _in = "fe80:0000:0000:0000:0204:61ff:fe9d:f156";
|
||||
var _out = IPv6.best(_in);
|
||||
var _expected = "fe80::204:61ff:fe9d:f156";
|
||||
|
||||
console.log(_in, _out, _expected, _out === _expected);
|
||||
*/
|
||||
|
||||
// save current IPv6 variable, if any
|
||||
var _IPv6 = root && root.IPv6;
|
||||
|
||||
function bestPresentation(address) {
|
||||
// based on:
|
||||
// Javascript to test an IPv6 address for proper format, and to
|
||||
// present the "best text representation" according to IETF Draft RFC at
|
||||
// http://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-04
|
||||
// 8 Feb 2010 Rich Brown, Dartware, LLC
|
||||
// Please feel free to use this code as long as you provide a link to
|
||||
// http://www.intermapper.com
|
||||
// http://intermapper.com/support/tools/IPV6-Validator.aspx
|
||||
// http://download.dartware.com/thirdparty/ipv6validator.js
|
||||
|
||||
var _address = address.toLowerCase();
|
||||
var segments = _address.split(':');
|
||||
var length = segments.length;
|
||||
var total = 8;
|
||||
|
||||
// trim colons (:: or ::a:b:c… or …a:b:c::)
|
||||
if (segments[0] === '' && segments[1] === '' && segments[2] === '') {
|
||||
// must have been ::
|
||||
// remove first two items
|
||||
segments.shift();
|
||||
segments.shift();
|
||||
} else if (segments[0] === '' && segments[1] === '') {
|
||||
// must have been ::xxxx
|
||||
// remove the first item
|
||||
segments.shift();
|
||||
} else if (segments[length - 1] === '' && segments[length - 2] === '') {
|
||||
// must have been xxxx::
|
||||
segments.pop();
|
||||
}
|
||||
|
||||
length = segments.length;
|
||||
|
||||
// adjust total segments for IPv4 trailer
|
||||
if (segments[length - 1].indexOf('.') !== -1) {
|
||||
// found a "." which means IPv4
|
||||
total = 7;
|
||||
}
|
||||
|
||||
// fill empty segments them with "0000"
|
||||
var pos;
|
||||
for (pos = 0; pos < length; pos++) {
|
||||
if (segments[pos] === '') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pos < total) {
|
||||
segments.splice(pos, 1, '0000');
|
||||
while (segments.length < total) {
|
||||
segments.splice(pos, 0, '0000');
|
||||
}
|
||||
}
|
||||
|
||||
// strip leading zeros
|
||||
var _segments;
|
||||
for (var i = 0; i < total; i++) {
|
||||
_segments = segments[i].split('');
|
||||
for (var j = 0; j < 3 ; j++) {
|
||||
if (_segments[0] === '0' && _segments.length > 1) {
|
||||
_segments.splice(0,1);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
segments[i] = _segments.join('');
|
||||
}
|
||||
|
||||
// find longest sequence of zeroes and coalesce them into one segment
|
||||
var best = -1;
|
||||
var _best = 0;
|
||||
var _current = 0;
|
||||
var current = -1;
|
||||
var inzeroes = false;
|
||||
// i; already declared
|
||||
|
||||
for (i = 0; i < total; i++) {
|
||||
if (inzeroes) {
|
||||
if (segments[i] === '0') {
|
||||
_current += 1;
|
||||
} else {
|
||||
inzeroes = false;
|
||||
if (_current > _best) {
|
||||
best = current;
|
||||
_best = _current;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (segments[i] === '0') {
|
||||
inzeroes = true;
|
||||
current = i;
|
||||
_current = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_current > _best) {
|
||||
best = current;
|
||||
_best = _current;
|
||||
}
|
||||
|
||||
if (_best > 1) {
|
||||
segments.splice(best, _best, '');
|
||||
}
|
||||
|
||||
length = segments.length;
|
||||
|
||||
// assemble remaining segments
|
||||
var result = '';
|
||||
if (segments[0] === '') {
|
||||
result = ':';
|
||||
}
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
result += segments[i];
|
||||
if (i === length - 1) {
|
||||
break;
|
||||
}
|
||||
|
||||
result += ':';
|
||||
}
|
||||
|
||||
if (segments[length - 1] === '') {
|
||||
result += ':';
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function noConflict() {
|
||||
/*jshint validthis: true */
|
||||
if (root.IPv6 === this) {
|
||||
root.IPv6 = _IPv6;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
return {
|
||||
best: bestPresentation,
|
||||
noConflict: noConflict
|
||||
};
|
||||
}));
|
||||
245
book/node_modules/urijs/src/SecondLevelDomains.js
generated
vendored
Normal file
245
book/node_modules/urijs/src/SecondLevelDomains.js
generated
vendored
Normal file
@@ -0,0 +1,245 @@
|
||||
/*!
|
||||
* URI.js - Mutating URLs
|
||||
* Second Level Domain (SLD) Support
|
||||
*
|
||||
* Version: 1.19.11
|
||||
*
|
||||
* Author: Rodney Rehm
|
||||
* Web: http://medialize.github.io/URI.js/
|
||||
*
|
||||
* Licensed under
|
||||
* MIT License http://www.opensource.org/licenses/mit-license
|
||||
*
|
||||
*/
|
||||
|
||||
(function (root, factory) {
|
||||
'use strict';
|
||||
// https://github.com/umdjs/umd/blob/master/returnExports.js
|
||||
if (typeof module === 'object' && module.exports) {
|
||||
// Node
|
||||
module.exports = factory();
|
||||
} else if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define(factory);
|
||||
} else {
|
||||
// Browser globals (root is window)
|
||||
root.SecondLevelDomains = factory(root);
|
||||
}
|
||||
}(this, function (root) {
|
||||
'use strict';
|
||||
|
||||
// save current SecondLevelDomains variable, if any
|
||||
var _SecondLevelDomains = root && root.SecondLevelDomains;
|
||||
|
||||
var SLD = {
|
||||
// list of known Second Level Domains
|
||||
// converted list of SLDs from https://github.com/gavingmiller/second-level-domains
|
||||
// ----
|
||||
// publicsuffix.org is more current and actually used by a couple of browsers internally.
|
||||
// downside is it also contains domains like "dyndns.org" - which is fine for the security
|
||||
// issues browser have to deal with (SOP for cookies, etc) - but is way overboard for URI.js
|
||||
// ----
|
||||
list: {
|
||||
'ac':' com gov mil net org ',
|
||||
'ae':' ac co gov mil name net org pro sch ',
|
||||
'af':' com edu gov net org ',
|
||||
'al':' com edu gov mil net org ',
|
||||
'ao':' co ed gv it og pb ',
|
||||
'ar':' com edu gob gov int mil net org tur ',
|
||||
'at':' ac co gv or ',
|
||||
'au':' asn com csiro edu gov id net org ',
|
||||
'ba':' co com edu gov mil net org rs unbi unmo unsa untz unze ',
|
||||
'bb':' biz co com edu gov info net org store tv ',
|
||||
'bh':' biz cc com edu gov info net org ',
|
||||
'bn':' com edu gov net org ',
|
||||
'bo':' com edu gob gov int mil net org tv ',
|
||||
'br':' adm adv agr am arq art ato b bio blog bmd cim cng cnt com coop ecn edu eng esp etc eti far flog fm fnd fot fst g12 ggf gov imb ind inf jor jus lel mat med mil mus net nom not ntr odo org ppg pro psc psi qsl rec slg srv tmp trd tur tv vet vlog wiki zlg ',
|
||||
'bs':' com edu gov net org ',
|
||||
'bz':' du et om ov rg ',
|
||||
'ca':' ab bc mb nb nf nl ns nt nu on pe qc sk yk ',
|
||||
'ck':' biz co edu gen gov info net org ',
|
||||
'cn':' ac ah bj com cq edu fj gd gov gs gx gz ha hb he hi hl hn jl js jx ln mil net nm nx org qh sc sd sh sn sx tj tw xj xz yn zj ',
|
||||
'co':' com edu gov mil net nom org ',
|
||||
'cr':' ac c co ed fi go or sa ',
|
||||
'cy':' ac biz com ekloges gov ltd name net org parliament press pro tm ',
|
||||
'do':' art com edu gob gov mil net org sld web ',
|
||||
'dz':' art asso com edu gov net org pol ',
|
||||
'ec':' com edu fin gov info med mil net org pro ',
|
||||
'eg':' com edu eun gov mil name net org sci ',
|
||||
'er':' com edu gov ind mil net org rochest w ',
|
||||
'es':' com edu gob nom org ',
|
||||
'et':' biz com edu gov info name net org ',
|
||||
'fj':' ac biz com info mil name net org pro ',
|
||||
'fk':' ac co gov net nom org ',
|
||||
'fr':' asso com f gouv nom prd presse tm ',
|
||||
'gg':' co net org ',
|
||||
'gh':' com edu gov mil org ',
|
||||
'gn':' ac com gov net org ',
|
||||
'gr':' com edu gov mil net org ',
|
||||
'gt':' com edu gob ind mil net org ',
|
||||
'gu':' com edu gov net org ',
|
||||
'hk':' com edu gov idv net org ',
|
||||
'hu':' 2000 agrar bolt casino city co erotica erotika film forum games hotel info ingatlan jogasz konyvelo lakas media news org priv reklam sex shop sport suli szex tm tozsde utazas video ',
|
||||
'id':' ac co go mil net or sch web ',
|
||||
'il':' ac co gov idf k12 muni net org ',
|
||||
'in':' ac co edu ernet firm gen gov i ind mil net nic org res ',
|
||||
'iq':' com edu gov i mil net org ',
|
||||
'ir':' ac co dnssec gov i id net org sch ',
|
||||
'it':' edu gov ',
|
||||
'je':' co net org ',
|
||||
'jo':' com edu gov mil name net org sch ',
|
||||
'jp':' ac ad co ed go gr lg ne or ',
|
||||
'ke':' ac co go info me mobi ne or sc ',
|
||||
'kh':' com edu gov mil net org per ',
|
||||
'ki':' biz com de edu gov info mob net org tel ',
|
||||
'km':' asso com coop edu gouv k medecin mil nom notaires pharmaciens presse tm veterinaire ',
|
||||
'kn':' edu gov net org ',
|
||||
'kr':' ac busan chungbuk chungnam co daegu daejeon es gangwon go gwangju gyeongbuk gyeonggi gyeongnam hs incheon jeju jeonbuk jeonnam k kg mil ms ne or pe re sc seoul ulsan ',
|
||||
'kw':' com edu gov net org ',
|
||||
'ky':' com edu gov net org ',
|
||||
'kz':' com edu gov mil net org ',
|
||||
'lb':' com edu gov net org ',
|
||||
'lk':' assn com edu gov grp hotel int ltd net ngo org sch soc web ',
|
||||
'lr':' com edu gov net org ',
|
||||
'lv':' asn com conf edu gov id mil net org ',
|
||||
'ly':' com edu gov id med net org plc sch ',
|
||||
'ma':' ac co gov m net org press ',
|
||||
'mc':' asso tm ',
|
||||
'me':' ac co edu gov its net org priv ',
|
||||
'mg':' com edu gov mil nom org prd tm ',
|
||||
'mk':' com edu gov inf name net org pro ',
|
||||
'ml':' com edu gov net org presse ',
|
||||
'mn':' edu gov org ',
|
||||
'mo':' com edu gov net org ',
|
||||
'mt':' com edu gov net org ',
|
||||
'mv':' aero biz com coop edu gov info int mil museum name net org pro ',
|
||||
'mw':' ac co com coop edu gov int museum net org ',
|
||||
'mx':' com edu gob net org ',
|
||||
'my':' com edu gov mil name net org sch ',
|
||||
'nf':' arts com firm info net other per rec store web ',
|
||||
'ng':' biz com edu gov mil mobi name net org sch ',
|
||||
'ni':' ac co com edu gob mil net nom org ',
|
||||
'np':' com edu gov mil net org ',
|
||||
'nr':' biz com edu gov info net org ',
|
||||
'om':' ac biz co com edu gov med mil museum net org pro sch ',
|
||||
'pe':' com edu gob mil net nom org sld ',
|
||||
'ph':' com edu gov i mil net ngo org ',
|
||||
'pk':' biz com edu fam gob gok gon gop gos gov net org web ',
|
||||
'pl':' art bialystok biz com edu gda gdansk gorzow gov info katowice krakow lodz lublin mil net ngo olsztyn org poznan pwr radom slupsk szczecin torun warszawa waw wroc wroclaw zgora ',
|
||||
'pr':' ac biz com edu est gov info isla name net org pro prof ',
|
||||
'ps':' com edu gov net org plo sec ',
|
||||
'pw':' belau co ed go ne or ',
|
||||
'ro':' arts com firm info nom nt org rec store tm www ',
|
||||
'rs':' ac co edu gov in org ',
|
||||
'sb':' com edu gov net org ',
|
||||
'sc':' com edu gov net org ',
|
||||
'sh':' co com edu gov net nom org ',
|
||||
'sl':' com edu gov net org ',
|
||||
'st':' co com consulado edu embaixada gov mil net org principe saotome store ',
|
||||
'sv':' com edu gob org red ',
|
||||
'sz':' ac co org ',
|
||||
'tr':' av bbs bel biz com dr edu gen gov info k12 name net org pol tel tsk tv web ',
|
||||
'tt':' aero biz cat co com coop edu gov info int jobs mil mobi museum name net org pro tel travel ',
|
||||
'tw':' club com ebiz edu game gov idv mil net org ',
|
||||
'mu':' ac co com gov net or org ',
|
||||
'mz':' ac co edu gov org ',
|
||||
'na':' co com ',
|
||||
'nz':' ac co cri geek gen govt health iwi maori mil net org parliament school ',
|
||||
'pa':' abo ac com edu gob ing med net nom org sld ',
|
||||
'pt':' com edu gov int net nome org publ ',
|
||||
'py':' com edu gov mil net org ',
|
||||
'qa':' com edu gov mil net org ',
|
||||
're':' asso com nom ',
|
||||
'ru':' ac adygeya altai amur arkhangelsk astrakhan bashkiria belgorod bir bryansk buryatia cbg chel chelyabinsk chita chukotka chuvashia com dagestan e-burg edu gov grozny int irkutsk ivanovo izhevsk jar joshkar-ola kalmykia kaluga kamchatka karelia kazan kchr kemerovo khabarovsk khakassia khv kirov koenig komi kostroma kranoyarsk kuban kurgan kursk lipetsk magadan mari mari-el marine mil mordovia mosreg msk murmansk nalchik net nnov nov novosibirsk nsk omsk orenburg org oryol penza perm pp pskov ptz rnd ryazan sakhalin samara saratov simbirsk smolensk spb stavropol stv surgut tambov tatarstan tom tomsk tsaritsyn tsk tula tuva tver tyumen udm udmurtia ulan-ude vladikavkaz vladimir vladivostok volgograd vologda voronezh vrn vyatka yakutia yamal yekaterinburg yuzhno-sakhalinsk ',
|
||||
'rw':' ac co com edu gouv gov int mil net ',
|
||||
'sa':' com edu gov med net org pub sch ',
|
||||
'sd':' com edu gov info med net org tv ',
|
||||
'se':' a ac b bd c d e f g h i k l m n o org p parti pp press r s t tm u w x y z ',
|
||||
'sg':' com edu gov idn net org per ',
|
||||
'sn':' art com edu gouv org perso univ ',
|
||||
'sy':' com edu gov mil net news org ',
|
||||
'th':' ac co go in mi net or ',
|
||||
'tj':' ac biz co com edu go gov info int mil name net nic org test web ',
|
||||
'tn':' agrinet com defense edunet ens fin gov ind info intl mincom nat net org perso rnrt rns rnu tourism ',
|
||||
'tz':' ac co go ne or ',
|
||||
'ua':' biz cherkassy chernigov chernovtsy ck cn co com crimea cv dn dnepropetrovsk donetsk dp edu gov if in ivano-frankivsk kh kharkov kherson khmelnitskiy kiev kirovograd km kr ks kv lg lugansk lutsk lviv me mk net nikolaev od odessa org pl poltava pp rovno rv sebastopol sumy te ternopil uzhgorod vinnica vn zaporizhzhe zhitomir zp zt ',
|
||||
'ug':' ac co go ne or org sc ',
|
||||
'uk':' ac bl british-library co cym gov govt icnet jet lea ltd me mil mod national-library-scotland nel net nhs nic nls org orgn parliament plc police sch scot soc ',
|
||||
'us':' dni fed isa kids nsn ',
|
||||
'uy':' com edu gub mil net org ',
|
||||
've':' co com edu gob info mil net org web ',
|
||||
'vi':' co com k12 net org ',
|
||||
'vn':' ac biz com edu gov health info int name net org pro ',
|
||||
'ye':' co com gov ltd me net org plc ',
|
||||
'yu':' ac co edu gov org ',
|
||||
'za':' ac agric alt bourse city co cybernet db edu gov grondar iaccess imt inca landesign law mil net ngo nis nom olivetti org pix school tm web ',
|
||||
'zm':' ac co com edu gov net org sch ',
|
||||
// https://en.wikipedia.org/wiki/CentralNic#Second-level_domains
|
||||
'com': 'ar br cn de eu gb gr hu jpn kr no qc ru sa se uk us uy za ',
|
||||
'net': 'gb jp se uk ',
|
||||
'org': 'ae',
|
||||
'de': 'com '
|
||||
},
|
||||
// gorhill 2013-10-25: Using indexOf() instead Regexp(). Significant boost
|
||||
// in both performance and memory footprint. No initialization required.
|
||||
// http://jsperf.com/uri-js-sld-regex-vs-binary-search/4
|
||||
// Following methods use lastIndexOf() rather than array.split() in order
|
||||
// to avoid any memory allocations.
|
||||
has: function(domain) {
|
||||
var tldOffset = domain.lastIndexOf('.');
|
||||
if (tldOffset <= 0 || tldOffset >= (domain.length-1)) {
|
||||
return false;
|
||||
}
|
||||
var sldOffset = domain.lastIndexOf('.', tldOffset-1);
|
||||
if (sldOffset <= 0 || sldOffset >= (tldOffset-1)) {
|
||||
return false;
|
||||
}
|
||||
var sldList = SLD.list[domain.slice(tldOffset+1)];
|
||||
if (!sldList) {
|
||||
return false;
|
||||
}
|
||||
return sldList.indexOf(' ' + domain.slice(sldOffset+1, tldOffset) + ' ') >= 0;
|
||||
},
|
||||
is: function(domain) {
|
||||
var tldOffset = domain.lastIndexOf('.');
|
||||
if (tldOffset <= 0 || tldOffset >= (domain.length-1)) {
|
||||
return false;
|
||||
}
|
||||
var sldOffset = domain.lastIndexOf('.', tldOffset-1);
|
||||
if (sldOffset >= 0) {
|
||||
return false;
|
||||
}
|
||||
var sldList = SLD.list[domain.slice(tldOffset+1)];
|
||||
if (!sldList) {
|
||||
return false;
|
||||
}
|
||||
return sldList.indexOf(' ' + domain.slice(0, tldOffset) + ' ') >= 0;
|
||||
},
|
||||
get: function(domain) {
|
||||
var tldOffset = domain.lastIndexOf('.');
|
||||
if (tldOffset <= 0 || tldOffset >= (domain.length-1)) {
|
||||
return null;
|
||||
}
|
||||
var sldOffset = domain.lastIndexOf('.', tldOffset-1);
|
||||
if (sldOffset <= 0 || sldOffset >= (tldOffset-1)) {
|
||||
return null;
|
||||
}
|
||||
var sldList = SLD.list[domain.slice(tldOffset+1)];
|
||||
if (!sldList) {
|
||||
return null;
|
||||
}
|
||||
if (sldList.indexOf(' ' + domain.slice(sldOffset+1, tldOffset) + ' ') < 0) {
|
||||
return null;
|
||||
}
|
||||
return domain.slice(sldOffset+1);
|
||||
},
|
||||
noConflict: function(){
|
||||
if (root.SecondLevelDomains === this) {
|
||||
root.SecondLevelDomains = _SecondLevelDomains;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
||||
return SLD;
|
||||
}));
|
||||
121
book/node_modules/urijs/src/URI.fragmentQuery.js
generated
vendored
Normal file
121
book/node_modules/urijs/src/URI.fragmentQuery.js
generated
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Extending URI.js for fragment abuse
|
||||
*/
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
// EXAMPLE: storing application/x-www-form-urlencoded data in the fragment
|
||||
// possibly helpful for Google's hashbangs
|
||||
// see http://code.google.com/web/ajaxcrawling/
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
// Note: make sure this is the last file loaded!
|
||||
|
||||
// USAGE:
|
||||
// var uri = URI("http://example.org/#?foo=bar");
|
||||
// uri.fragment(true) === {foo: "bar"};
|
||||
// uri.fragment({bar: "foo"});
|
||||
// uri.toString() === "http://example.org/#?bar=foo";
|
||||
// uri.addFragment("name", "value");
|
||||
// uri.toString() === "http://example.org/#?bar=foo&name=value";
|
||||
// uri.removeFragment("name");
|
||||
// uri.toString() === "http://example.org/#?bar=foo";
|
||||
// uri.setFragment("name", "value1");
|
||||
// uri.toString() === "http://example.org/#?bar=foo&name=value1";
|
||||
// uri.setFragment("name", "value2");
|
||||
// uri.toString() === "http://example.org/#?bar=foo&name=value2";
|
||||
|
||||
(function (root, factory) {
|
||||
'use strict';
|
||||
// https://github.com/umdjs/umd/blob/master/returnExports.js
|
||||
if (typeof module === 'object' && module.exports) {
|
||||
// Node
|
||||
module.exports = factory(require('./URI'));
|
||||
} else if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define(['./URI'], factory);
|
||||
} else {
|
||||
// Browser globals (root is window)
|
||||
factory(root.URI);
|
||||
}
|
||||
}(this, function (URI) {
|
||||
'use strict';
|
||||
|
||||
var p = URI.prototype;
|
||||
// old fragment handler we need to wrap
|
||||
var f = p.fragment;
|
||||
|
||||
// make fragmentPrefix configurable
|
||||
URI.fragmentPrefix = '?';
|
||||
var _parts = URI._parts;
|
||||
URI._parts = function() {
|
||||
var parts = _parts();
|
||||
parts.fragmentPrefix = URI.fragmentPrefix;
|
||||
return parts;
|
||||
};
|
||||
p.fragmentPrefix = function(v) {
|
||||
this._parts.fragmentPrefix = v;
|
||||
return this;
|
||||
};
|
||||
|
||||
// add fragment(true) and fragment({key: value}) signatures
|
||||
p.fragment = function(v, build) {
|
||||
var prefix = this._parts.fragmentPrefix;
|
||||
var fragment = this._parts.fragment || '';
|
||||
|
||||
if (v === true) {
|
||||
if (fragment.substring(0, prefix.length) !== prefix) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return URI.parseQuery(fragment.substring(prefix.length));
|
||||
} else if (v !== undefined && typeof v !== 'string') {
|
||||
this._parts.fragment = prefix + URI.buildQuery(v);
|
||||
this.build(!build);
|
||||
return this;
|
||||
} else {
|
||||
return f.call(this, v, build);
|
||||
}
|
||||
};
|
||||
p.addFragment = function(name, value, build) {
|
||||
var prefix = this._parts.fragmentPrefix;
|
||||
var data = URI.parseQuery((this._parts.fragment || '').substring(prefix.length));
|
||||
URI.addQuery(data, name, value);
|
||||
this._parts.fragment = prefix + URI.buildQuery(data);
|
||||
if (typeof name !== 'string') {
|
||||
build = value;
|
||||
}
|
||||
|
||||
this.build(!build);
|
||||
return this;
|
||||
};
|
||||
p.removeFragment = function(name, value, build) {
|
||||
var prefix = this._parts.fragmentPrefix;
|
||||
var data = URI.parseQuery((this._parts.fragment || '').substring(prefix.length));
|
||||
URI.removeQuery(data, name, value);
|
||||
this._parts.fragment = prefix + URI.buildQuery(data);
|
||||
if (typeof name !== 'string') {
|
||||
build = value;
|
||||
}
|
||||
|
||||
this.build(!build);
|
||||
return this;
|
||||
};
|
||||
p.setFragment = function(name, value, build) {
|
||||
var prefix = this._parts.fragmentPrefix;
|
||||
var data = URI.parseQuery((this._parts.fragment || '').substring(prefix.length));
|
||||
URI.setQuery(data, name, value);
|
||||
this._parts.fragment = prefix + URI.buildQuery(data);
|
||||
if (typeof name !== 'string') {
|
||||
build = value;
|
||||
}
|
||||
|
||||
this.build(!build);
|
||||
return this;
|
||||
};
|
||||
p.addHash = p.addFragment;
|
||||
p.removeHash = p.removeFragment;
|
||||
p.setHash = p.setFragment;
|
||||
|
||||
// extending existing object rather than defining something new
|
||||
return URI;
|
||||
}));
|
||||
97
book/node_modules/urijs/src/URI.fragmentURI.js
generated
vendored
Normal file
97
book/node_modules/urijs/src/URI.fragmentURI.js
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Extending URI.js for fragment abuse
|
||||
*/
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
// EXAMPLE: storing a relative URL in the fragment ("FragmentURI")
|
||||
// possibly helpful when working with backbone.js or sammy.js
|
||||
// inspired by https://github.com/medialize/URI.js/pull/2
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
// Note: make sure this is the last file loaded!
|
||||
|
||||
// USAGE:
|
||||
// var uri = URI("http://example.org/#!/foo/bar/baz.html");
|
||||
// var furi = uri.fragment(true);
|
||||
// furi.pathname() === '/foo/bar/baz.html';
|
||||
// furi.pathname('/hello.html');
|
||||
// uri.toString() === "http://example.org/#!/hello.html"
|
||||
|
||||
(function (root, factory) {
|
||||
'use strict';
|
||||
// https://github.com/umdjs/umd/blob/master/returnExports.js
|
||||
if (typeof module === 'object' && module.exports) {
|
||||
// Node
|
||||
module.exports = factory(require('./URI'));
|
||||
} else if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define(['./URI'], factory);
|
||||
} else {
|
||||
// Browser globals (root is window)
|
||||
factory(root.URI);
|
||||
}
|
||||
}(this, function (URI) {
|
||||
'use strict';
|
||||
|
||||
var p = URI.prototype;
|
||||
// old handlers we need to wrap
|
||||
var f = p.fragment;
|
||||
var b = p.build;
|
||||
|
||||
// make fragmentPrefix configurable
|
||||
URI.fragmentPrefix = '!';
|
||||
var _parts = URI._parts;
|
||||
URI._parts = function() {
|
||||
var parts = _parts();
|
||||
parts.fragmentPrefix = URI.fragmentPrefix;
|
||||
return parts;
|
||||
};
|
||||
p.fragmentPrefix = function(v) {
|
||||
this._parts.fragmentPrefix = v;
|
||||
return this;
|
||||
};
|
||||
|
||||
// add fragment(true) and fragment(URI) signatures
|
||||
p.fragment = function(v, build) {
|
||||
var prefix = this._parts.fragmentPrefix;
|
||||
var fragment = this._parts.fragment || '';
|
||||
var furi;
|
||||
|
||||
if (v === true) {
|
||||
if (fragment.substring(0, prefix.length) !== prefix) {
|
||||
furi = URI('');
|
||||
} else {
|
||||
furi = new URI(fragment.substring(prefix.length));
|
||||
}
|
||||
|
||||
this._fragmentURI = furi;
|
||||
furi._parentURI = this;
|
||||
return furi;
|
||||
} else if (v !== undefined && typeof v !== 'string') {
|
||||
this._fragmentURI = v;
|
||||
v._parentURI = v;
|
||||
this._parts.fragment = prefix + v.toString();
|
||||
this.build(!build);
|
||||
return this;
|
||||
} else if (typeof v === 'string') {
|
||||
this._fragmentURI = undefined;
|
||||
}
|
||||
|
||||
return f.call(this, v, build);
|
||||
};
|
||||
|
||||
// make .build() of the actual URI aware of the FragmentURI
|
||||
p.build = function(deferBuild) {
|
||||
var t = b.call(this, deferBuild);
|
||||
|
||||
if (deferBuild !== false && this._parentURI) {
|
||||
// update the parent
|
||||
this._parentURI.fragment(this);
|
||||
}
|
||||
|
||||
return t;
|
||||
};
|
||||
|
||||
// extending existing object rather than defining something new
|
||||
return URI;
|
||||
}));
|
||||
2364
book/node_modules/urijs/src/URI.js
generated
vendored
Normal file
2364
book/node_modules/urijs/src/URI.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
94
book/node_modules/urijs/src/URI.min.js
generated
vendored
Normal file
94
book/node_modules/urijs/src/URI.min.js
generated
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
/*! URI.js v1.19.11 http://medialize.github.io/URI.js/ */
|
||||
/* build contains: IPv6.js, punycode.js, SecondLevelDomains.js, URI.js, URITemplate.js */
|
||||
(function(r,x){"object"===typeof module&&module.exports?module.exports=x():"function"===typeof define&&define.amd?define(x):r.IPv6=x(r)})(this,function(r){var x=r&&r.IPv6;return{best:function(k){k=k.toLowerCase().split(":");var m=k.length,d=8;""===k[0]&&""===k[1]&&""===k[2]?(k.shift(),k.shift()):""===k[0]&&""===k[1]?k.shift():""===k[m-1]&&""===k[m-2]&&k.pop();m=k.length;-1!==k[m-1].indexOf(".")&&(d=7);var q;for(q=0;q<m&&""!==k[q];q++);if(q<d)for(k.splice(q,1,"0000");k.length<d;)k.splice(q,0,"0000");
|
||||
for(q=0;q<d;q++){m=k[q].split("");for(var E=0;3>E;E++)if("0"===m[0]&&1<m.length)m.splice(0,1);else break;k[q]=m.join("")}m=-1;var A=E=0,h=-1,p=!1;for(q=0;q<d;q++)p?"0"===k[q]?A+=1:(p=!1,A>E&&(m=h,E=A)):"0"===k[q]&&(p=!0,h=q,A=1);A>E&&(m=h,E=A);1<E&&k.splice(m,E,"");m=k.length;d="";""===k[0]&&(d=":");for(q=0;q<m;q++){d+=k[q];if(q===m-1)break;d+=":"}""===k[m-1]&&(d+=":");return d},noConflict:function(){r.IPv6===this&&(r.IPv6=x);return this}}});
|
||||
(function(r){function x(l){throw new RangeError(H[l]);}function k(l,t){for(var C=l.length,y=[];C--;)y[C]=t(l[C]);return y}function m(l,t){var C=l.split("@"),y="";1<C.length&&(y=C[0]+"@",l=C[1]);l=l.replace(w,".");C=l.split(".");C=k(C,t).join(".");return y+C}function d(l){for(var t=[],C=0,y=l.length,J,M;C<y;)J=l.charCodeAt(C++),55296<=J&&56319>=J&&C<y?(M=l.charCodeAt(C++),56320==(M&64512)?t.push(((J&1023)<<10)+(M&1023)+65536):(t.push(J),C--)):t.push(J);return t}function q(l){return k(l,function(t){var C=
|
||||
"";65535<t&&(t-=65536,C+=g(t>>>10&1023|55296),t=56320|t&1023);return C+=g(t)}).join("")}function E(l,t,C){var y=0;l=C?v(l/700):l>>1;for(l+=v(l/t);455<l;y+=36)l=v(l/35);return v(y+36*l/(l+38))}function A(l){var t=[],C=l.length,y=0,J=128,M=72,a,b;var c=l.lastIndexOf("-");0>c&&(c=0);for(a=0;a<c;++a)128<=l.charCodeAt(a)&&x("not-basic"),t.push(l.charCodeAt(a));for(c=0<c?c+1:0;c<C;){a=y;var e=1;for(b=36;;b+=36){c>=C&&x("invalid-input");var f=l.charCodeAt(c++);f=10>f-48?f-22:26>f-65?f-65:26>f-97?f-97:36;
|
||||
(36<=f||f>v((2147483647-y)/e))&&x("overflow");y+=f*e;var n=b<=M?1:b>=M+26?26:b-M;if(f<n)break;f=36-n;e>v(2147483647/f)&&x("overflow");e*=f}e=t.length+1;M=E(y-a,e,0==a);v(y/e)>2147483647-J&&x("overflow");J+=v(y/e);y%=e;t.splice(y++,0,J)}return q(t)}function h(l){var t,C,y,J=[];l=d(l);var M=l.length;var a=128;var b=0;var c=72;for(y=0;y<M;++y){var e=l[y];128>e&&J.push(g(e))}for((t=C=J.length)&&J.push("-");t<M;){var f=2147483647;for(y=0;y<M;++y)e=l[y],e>=a&&e<f&&(f=e);var n=t+1;f-a>v((2147483647-b)/n)&&
|
||||
x("overflow");b+=(f-a)*n;a=f;for(y=0;y<M;++y)if(e=l[y],e<a&&2147483647<++b&&x("overflow"),e==a){var z=b;for(f=36;;f+=36){e=f<=c?1:f>=c+26?26:f-c;if(z<e)break;var I=z-e;z=36-e;var L=J;e+=I%z;L.push.call(L,g(e+22+75*(26>e)-0));z=v(I/z)}J.push(g(z+22+75*(26>z)-0));c=E(b,n,t==C);b=0;++t}++b;++a}return J.join("")}var p="object"==typeof exports&&exports&&!exports.nodeType&&exports,D="object"==typeof module&&module&&!module.nodeType&&module,u="object"==typeof global&&global;if(u.global===u||u.window===u||
|
||||
u.self===u)r=u;var K=/^xn--/,F=/[^\x20-\x7E]/,w=/[\x2E\u3002\uFF0E\uFF61]/g,H={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},v=Math.floor,g=String.fromCharCode,B;var G={version:"1.3.2",ucs2:{decode:d,encode:q},decode:A,encode:h,toASCII:function(l){return m(l,function(t){return F.test(t)?"xn--"+h(t):t})},toUnicode:function(l){return m(l,function(t){return K.test(t)?A(t.slice(4).toLowerCase()):
|
||||
t})}};if("function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",function(){return G});else if(p&&D)if(module.exports==p)D.exports=G;else for(B in G)G.hasOwnProperty(B)&&(p[B]=G[B]);else r.punycode=G})(this);
|
||||
(function(r,x){"object"===typeof module&&module.exports?module.exports=x():"function"===typeof define&&define.amd?define(x):r.SecondLevelDomains=x(r)})(this,function(r){var x=r&&r.SecondLevelDomains,k={list:{ac:" com gov mil net org ",ae:" ac co gov mil name net org pro sch ",af:" com edu gov net org ",al:" com edu gov mil net org ",ao:" co ed gv it og pb ",ar:" com edu gob gov int mil net org tur ",at:" ac co gv or ",au:" asn com csiro edu gov id net org ",ba:" co com edu gov mil net org rs unbi unmo unsa untz unze ",
|
||||
bb:" biz co com edu gov info net org store tv ",bh:" biz cc com edu gov info net org ",bn:" com edu gov net org ",bo:" com edu gob gov int mil net org tv ",br:" adm adv agr am arq art ato b bio blog bmd cim cng cnt com coop ecn edu eng esp etc eti far flog fm fnd fot fst g12 ggf gov imb ind inf jor jus lel mat med mil mus net nom not ntr odo org ppg pro psc psi qsl rec slg srv tmp trd tur tv vet vlog wiki zlg ",bs:" com edu gov net org ",bz:" du et om ov rg ",ca:" ab bc mb nb nf nl ns nt nu on pe qc sk yk ",
|
||||
ck:" biz co edu gen gov info net org ",cn:" ac ah bj com cq edu fj gd gov gs gx gz ha hb he hi hl hn jl js jx ln mil net nm nx org qh sc sd sh sn sx tj tw xj xz yn zj ",co:" com edu gov mil net nom org ",cr:" ac c co ed fi go or sa ",cy:" ac biz com ekloges gov ltd name net org parliament press pro tm ","do":" art com edu gob gov mil net org sld web ",dz:" art asso com edu gov net org pol ",ec:" com edu fin gov info med mil net org pro ",eg:" com edu eun gov mil name net org sci ",er:" com edu gov ind mil net org rochest w ",
|
||||
es:" com edu gob nom org ",et:" biz com edu gov info name net org ",fj:" ac biz com info mil name net org pro ",fk:" ac co gov net nom org ",fr:" asso com f gouv nom prd presse tm ",gg:" co net org ",gh:" com edu gov mil org ",gn:" ac com gov net org ",gr:" com edu gov mil net org ",gt:" com edu gob ind mil net org ",gu:" com edu gov net org ",hk:" com edu gov idv net org ",hu:" 2000 agrar bolt casino city co erotica erotika film forum games hotel info ingatlan jogasz konyvelo lakas media news org priv reklam sex shop sport suli szex tm tozsde utazas video ",
|
||||
id:" ac co go mil net or sch web ",il:" ac co gov idf k12 muni net org ","in":" ac co edu ernet firm gen gov i ind mil net nic org res ",iq:" com edu gov i mil net org ",ir:" ac co dnssec gov i id net org sch ",it:" edu gov ",je:" co net org ",jo:" com edu gov mil name net org sch ",jp:" ac ad co ed go gr lg ne or ",ke:" ac co go info me mobi ne or sc ",kh:" com edu gov mil net org per ",ki:" biz com de edu gov info mob net org tel ",km:" asso com coop edu gouv k medecin mil nom notaires pharmaciens presse tm veterinaire ",
|
||||
kn:" edu gov net org ",kr:" ac busan chungbuk chungnam co daegu daejeon es gangwon go gwangju gyeongbuk gyeonggi gyeongnam hs incheon jeju jeonbuk jeonnam k kg mil ms ne or pe re sc seoul ulsan ",kw:" com edu gov net org ",ky:" com edu gov net org ",kz:" com edu gov mil net org ",lb:" com edu gov net org ",lk:" assn com edu gov grp hotel int ltd net ngo org sch soc web ",lr:" com edu gov net org ",lv:" asn com conf edu gov id mil net org ",ly:" com edu gov id med net org plc sch ",ma:" ac co gov m net org press ",
|
||||
mc:" asso tm ",me:" ac co edu gov its net org priv ",mg:" com edu gov mil nom org prd tm ",mk:" com edu gov inf name net org pro ",ml:" com edu gov net org presse ",mn:" edu gov org ",mo:" com edu gov net org ",mt:" com edu gov net org ",mv:" aero biz com coop edu gov info int mil museum name net org pro ",mw:" ac co com coop edu gov int museum net org ",mx:" com edu gob net org ",my:" com edu gov mil name net org sch ",nf:" arts com firm info net other per rec store web ",ng:" biz com edu gov mil mobi name net org sch ",
|
||||
ni:" ac co com edu gob mil net nom org ",np:" com edu gov mil net org ",nr:" biz com edu gov info net org ",om:" ac biz co com edu gov med mil museum net org pro sch ",pe:" com edu gob mil net nom org sld ",ph:" com edu gov i mil net ngo org ",pk:" biz com edu fam gob gok gon gop gos gov net org web ",pl:" art bialystok biz com edu gda gdansk gorzow gov info katowice krakow lodz lublin mil net ngo olsztyn org poznan pwr radom slupsk szczecin torun warszawa waw wroc wroclaw zgora ",pr:" ac biz com edu est gov info isla name net org pro prof ",
|
||||
ps:" com edu gov net org plo sec ",pw:" belau co ed go ne or ",ro:" arts com firm info nom nt org rec store tm www ",rs:" ac co edu gov in org ",sb:" com edu gov net org ",sc:" com edu gov net org ",sh:" co com edu gov net nom org ",sl:" com edu gov net org ",st:" co com consulado edu embaixada gov mil net org principe saotome store ",sv:" com edu gob org red ",sz:" ac co org ",tr:" av bbs bel biz com dr edu gen gov info k12 name net org pol tel tsk tv web ",tt:" aero biz cat co com coop edu gov info int jobs mil mobi museum name net org pro tel travel ",
|
||||
tw:" club com ebiz edu game gov idv mil net org ",mu:" ac co com gov net or org ",mz:" ac co edu gov org ",na:" co com ",nz:" ac co cri geek gen govt health iwi maori mil net org parliament school ",pa:" abo ac com edu gob ing med net nom org sld ",pt:" com edu gov int net nome org publ ",py:" com edu gov mil net org ",qa:" com edu gov mil net org ",re:" asso com nom ",ru:" ac adygeya altai amur arkhangelsk astrakhan bashkiria belgorod bir bryansk buryatia cbg chel chelyabinsk chita chukotka chuvashia com dagestan e-burg edu gov grozny int irkutsk ivanovo izhevsk jar joshkar-ola kalmykia kaluga kamchatka karelia kazan kchr kemerovo khabarovsk khakassia khv kirov koenig komi kostroma kranoyarsk kuban kurgan kursk lipetsk magadan mari mari-el marine mil mordovia mosreg msk murmansk nalchik net nnov nov novosibirsk nsk omsk orenburg org oryol penza perm pp pskov ptz rnd ryazan sakhalin samara saratov simbirsk smolensk spb stavropol stv surgut tambov tatarstan tom tomsk tsaritsyn tsk tula tuva tver tyumen udm udmurtia ulan-ude vladikavkaz vladimir vladivostok volgograd vologda voronezh vrn vyatka yakutia yamal yekaterinburg yuzhno-sakhalinsk ",
|
||||
rw:" ac co com edu gouv gov int mil net ",sa:" com edu gov med net org pub sch ",sd:" com edu gov info med net org tv ",se:" a ac b bd c d e f g h i k l m n o org p parti pp press r s t tm u w x y z ",sg:" com edu gov idn net org per ",sn:" art com edu gouv org perso univ ",sy:" com edu gov mil net news org ",th:" ac co go in mi net or ",tj:" ac biz co com edu go gov info int mil name net nic org test web ",tn:" agrinet com defense edunet ens fin gov ind info intl mincom nat net org perso rnrt rns rnu tourism ",
|
||||
tz:" ac co go ne or ",ua:" biz cherkassy chernigov chernovtsy ck cn co com crimea cv dn dnepropetrovsk donetsk dp edu gov if in ivano-frankivsk kh kharkov kherson khmelnitskiy kiev kirovograd km kr ks kv lg lugansk lutsk lviv me mk net nikolaev od odessa org pl poltava pp rovno rv sebastopol sumy te ternopil uzhgorod vinnica vn zaporizhzhe zhitomir zp zt ",ug:" ac co go ne or org sc ",uk:" ac bl british-library co cym gov govt icnet jet lea ltd me mil mod national-library-scotland nel net nhs nic nls org orgn parliament plc police sch scot soc ",
|
||||
us:" dni fed isa kids nsn ",uy:" com edu gub mil net org ",ve:" co com edu gob info mil net org web ",vi:" co com k12 net org ",vn:" ac biz com edu gov health info int name net org pro ",ye:" co com gov ltd me net org plc ",yu:" ac co edu gov org ",za:" ac agric alt bourse city co cybernet db edu gov grondar iaccess imt inca landesign law mil net ngo nis nom olivetti org pix school tm web ",zm:" ac co com edu gov net org sch ",com:"ar br cn de eu gb gr hu jpn kr no qc ru sa se uk us uy za ",net:"gb jp se uk ",
|
||||
org:"ae",de:"com "},has:function(m){var d=m.lastIndexOf(".");if(0>=d||d>=m.length-1)return!1;var q=m.lastIndexOf(".",d-1);if(0>=q||q>=d-1)return!1;var E=k.list[m.slice(d+1)];return E?0<=E.indexOf(" "+m.slice(q+1,d)+" "):!1},is:function(m){var d=m.lastIndexOf(".");if(0>=d||d>=m.length-1||0<=m.lastIndexOf(".",d-1))return!1;var q=k.list[m.slice(d+1)];return q?0<=q.indexOf(" "+m.slice(0,d)+" "):!1},get:function(m){var d=m.lastIndexOf(".");if(0>=d||d>=m.length-1)return null;var q=m.lastIndexOf(".",d-1);
|
||||
if(0>=q||q>=d-1)return null;var E=k.list[m.slice(d+1)];return!E||0>E.indexOf(" "+m.slice(q+1,d)+" ")?null:m.slice(q+1)},noConflict:function(){r.SecondLevelDomains===this&&(r.SecondLevelDomains=x);return this}};return k});
|
||||
(function(r,x){"object"===typeof module&&module.exports?module.exports=x(require("./punycode"),require("./IPv6"),require("./SecondLevelDomains")):"function"===typeof define&&define.amd?define(["./punycode","./IPv6","./SecondLevelDomains"],x):r.URI=x(r.punycode,r.IPv6,r.SecondLevelDomains,r)})(this,function(r,x,k,m){function d(a,b){var c=1<=arguments.length,e=2<=arguments.length;if(!(this instanceof d))return c?e?new d(a,b):new d(a):new d;if(void 0===a){if(c)throw new TypeError("undefined is not a valid argument for URI");
|
||||
a="undefined"!==typeof location?location.href+"":""}if(null===a&&c)throw new TypeError("null is not a valid argument for URI");this.href(a);return void 0!==b?this.absoluteTo(b):this}function q(a){return a.replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}function E(a){return void 0===a?"Undefined":String(Object.prototype.toString.call(a)).slice(8,-1)}function A(a){return"Array"===E(a)}function h(a,b){var c={},e;if("RegExp"===E(b))c=null;else if(A(b)){var f=0;for(e=b.length;f<e;f++)c[b[f]]=!0}else c[b]=
|
||||
!0;f=0;for(e=a.length;f<e;f++)if(c&&void 0!==c[a[f]]||!c&&b.test(a[f]))a.splice(f,1),e--,f--;return a}function p(a,b){var c;if(A(b)){var e=0;for(c=b.length;e<c;e++)if(!p(a,b[e]))return!1;return!0}var f=E(b);e=0;for(c=a.length;e<c;e++)if("RegExp"===f){if("string"===typeof a[e]&&a[e].match(b))return!0}else if(a[e]===b)return!0;return!1}function D(a,b){if(!A(a)||!A(b)||a.length!==b.length)return!1;a.sort();b.sort();for(var c=0,e=a.length;c<e;c++)if(a[c]!==b[c])return!1;return!0}function u(a){return a.replace(/^\/+|\/+$/g,
|
||||
"")}function K(a){return escape(a)}function F(a){return encodeURIComponent(a).replace(/[!'()*]/g,K).replace(/\*/g,"%2A")}function w(a){return function(b,c){if(void 0===b)return this._parts[a]||"";this._parts[a]=b||null;this.build(!c);return this}}function H(a,b){return function(c,e){if(void 0===c)return this._parts[a]||"";null!==c&&(c+="",c.charAt(0)===b&&(c=c.substring(1)));this._parts[a]=c;this.build(!e);return this}}var v=m&&m.URI;d.version="1.19.11";var g=d.prototype,B=Object.prototype.hasOwnProperty;
|
||||
d._parts=function(){return{protocol:null,username:null,password:null,hostname:null,urn:null,port:null,path:null,query:null,fragment:null,preventInvalidHostname:d.preventInvalidHostname,duplicateQueryParameters:d.duplicateQueryParameters,escapeQuerySpace:d.escapeQuerySpace}};d.preventInvalidHostname=!1;d.duplicateQueryParameters=!1;d.escapeQuerySpace=!0;d.protocol_expression=/^[a-z][a-z0-9.+-]*$/i;d.idn_expression=/[^a-z0-9\._-]/i;d.punycode_expression=/(xn--)/i;d.ip4_expression=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
|
||||
d.ip6_expression=/^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/;
|
||||
d.find_uri_expression=/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?\u00ab\u00bb\u201c\u201d\u2018\u2019]))/ig;d.findUri={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,end:/[\s\r\n]|$/,trim:/[`!()\[\]{};:'".,<>?\u00ab\u00bb\u201c\u201d\u201e\u2018\u2019]+$/,parens:/(\([^\)]*\)|\[[^\]]*\]|\{[^}]*\}|<[^>]*>)/g};d.leading_whitespace_expression=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/;
|
||||
d.ascii_tab_whitespace=/[\u0009\u000A\u000D]+/g;d.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"};d.hostProtocols=["http","https"];d.invalid_hostname_characters=/[^a-zA-Z0-9\.\-:_]/;d.domAttributes={a:"href",blockquote:"cite",link:"href",base:"href",script:"src",form:"action",img:"src",area:"href",iframe:"src",embed:"src",source:"src",track:"src",input:"src",audio:"src",video:"src"};d.getDomAttribute=function(a){if(a&&a.nodeName){var b=a.nodeName.toLowerCase();if("input"!==
|
||||
b||"image"===a.type)return d.domAttributes[b]}};d.encode=F;d.decode=decodeURIComponent;d.iso8859=function(){d.encode=escape;d.decode=unescape};d.unicode=function(){d.encode=F;d.decode=decodeURIComponent};d.characters={pathname:{encode:{expression:/%(24|26|2B|2C|3B|3D|3A|40)/ig,map:{"%24":"$","%26":"&","%2B":"+","%2C":",","%3B":";","%3D":"=","%3A":":","%40":"@"}},decode:{expression:/[\/\?#]/g,map:{"/":"%2F","?":"%3F","#":"%23"}}},reserved:{encode:{expression:/%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/ig,
|
||||
map:{"%3A":":","%2F":"/","%3F":"?","%23":"#","%5B":"[","%5D":"]","%40":"@","%21":"!","%24":"$","%26":"&","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"="}}},urnpath:{encode:{expression:/%(21|24|27|28|29|2A|2B|2C|3B|3D|40)/ig,map:{"%21":"!","%24":"$","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"=","%40":"@"}},decode:{expression:/[\/\?#:]/g,map:{"/":"%2F","?":"%3F","#":"%23",":":"%3A"}}}};d.encodeQuery=function(a,b){var c=d.encode(a+"");
|
||||
void 0===b&&(b=d.escapeQuerySpace);return b?c.replace(/%20/g,"+"):c};d.decodeQuery=function(a,b){a+="";void 0===b&&(b=d.escapeQuerySpace);try{return d.decode(b?a.replace(/\+/g,"%20"):a)}catch(c){return a}};var G={encode:"encode",decode:"decode"},l,t=function(a,b){return function(c){try{return d[b](c+"").replace(d.characters[a][b].expression,function(e){return d.characters[a][b].map[e]})}catch(e){return c}}};for(l in G)d[l+"PathSegment"]=t("pathname",G[l]),d[l+"UrnPathSegment"]=t("urnpath",G[l]);G=
|
||||
function(a,b,c){return function(e){var f=c?function(I){return d[b](d[c](I))}:d[b];e=(e+"").split(a);for(var n=0,z=e.length;n<z;n++)e[n]=f(e[n]);return e.join(a)}};d.decodePath=G("/","decodePathSegment");d.decodeUrnPath=G(":","decodeUrnPathSegment");d.recodePath=G("/","encodePathSegment","decode");d.recodeUrnPath=G(":","encodeUrnPathSegment","decode");d.encodeReserved=t("reserved","encode");d.parse=function(a,b){b||(b={preventInvalidHostname:d.preventInvalidHostname});a=a.replace(d.leading_whitespace_expression,
|
||||
"");a=a.replace(d.ascii_tab_whitespace,"");var c=a.indexOf("#");-1<c&&(b.fragment=a.substring(c+1)||null,a=a.substring(0,c));c=a.indexOf("?");-1<c&&(b.query=a.substring(c+1)||null,a=a.substring(0,c));a=a.replace(/^(https?|ftp|wss?)?:+[/\\]*/i,"$1://");a=a.replace(/^[/\\]{2,}/i,"//");"//"===a.substring(0,2)?(b.protocol=null,a=a.substring(2),a=d.parseAuthority(a,b)):(c=a.indexOf(":"),-1<c&&(b.protocol=a.substring(0,c)||null,b.protocol&&!b.protocol.match(d.protocol_expression)?b.protocol=void 0:"//"===
|
||||
a.substring(c+1,c+3).replace(/\\/g,"/")?(a=a.substring(c+3),a=d.parseAuthority(a,b)):(a=a.substring(c+1),b.urn=!0)));b.path=a;return b};d.parseHost=function(a,b){a||(a="");a=a.replace(/\\/g,"/");var c=a.indexOf("/");-1===c&&(c=a.length);if("["===a.charAt(0)){var e=a.indexOf("]");b.hostname=a.substring(1,e)||null;b.port=a.substring(e+2,c)||null;"/"===b.port&&(b.port=null)}else{var f=a.indexOf(":");e=a.indexOf("/");f=a.indexOf(":",f+1);-1!==f&&(-1===e||f<e)?(b.hostname=a.substring(0,c)||null,b.port=
|
||||
null):(e=a.substring(0,c).split(":"),b.hostname=e[0]||null,b.port=e[1]||null)}b.hostname&&"/"!==a.substring(c).charAt(0)&&(c++,a="/"+a);b.preventInvalidHostname&&d.ensureValidHostname(b.hostname,b.protocol);b.port&&d.ensureValidPort(b.port);return a.substring(c)||"/"};d.parseAuthority=function(a,b){a=d.parseUserinfo(a,b);return d.parseHost(a,b)};d.parseUserinfo=function(a,b){var c=a;-1!==a.indexOf("\\")&&(a=a.replace(/\\/g,"/"));var e=a.indexOf("/"),f=a.lastIndexOf("@",-1<e?e:a.length-1);-1<f&&(-1===
|
||||
e||f<e)?(e=a.substring(0,f).split(":"),b.username=e[0]?d.decode(e[0]):null,e.shift(),b.password=e[0]?d.decode(e.join(":")):null,a=c.substring(f+1)):(b.username=null,b.password=null);return a};d.parseQuery=function(a,b){if(!a)return{};a=a.replace(/&+/g,"&").replace(/^\?*&*|&+$/g,"");if(!a)return{};for(var c={},e=a.split("&"),f=e.length,n,z,I=0;I<f;I++)if(n=e[I].split("="),z=d.decodeQuery(n.shift(),b),n=n.length?d.decodeQuery(n.join("="),b):null,"__proto__"!==z)if(B.call(c,z)){if("string"===typeof c[z]||
|
||||
null===c[z])c[z]=[c[z]];c[z].push(n)}else c[z]=n;return c};d.build=function(a){var b="",c=!1;a.protocol&&(b+=a.protocol+":");a.urn||!b&&!a.hostname||(b+="//",c=!0);b+=d.buildAuthority(a)||"";"string"===typeof a.path&&("/"!==a.path.charAt(0)&&c&&(b+="/"),b+=a.path);"string"===typeof a.query&&a.query&&(b+="?"+a.query);"string"===typeof a.fragment&&a.fragment&&(b+="#"+a.fragment);return b};d.buildHost=function(a){var b="";if(a.hostname)b=d.ip6_expression.test(a.hostname)?b+("["+a.hostname+"]"):b+a.hostname;
|
||||
else return"";a.port&&(b+=":"+a.port);return b};d.buildAuthority=function(a){return d.buildUserinfo(a)+d.buildHost(a)};d.buildUserinfo=function(a){var b="";a.username&&(b+=d.encode(a.username));a.password&&(b+=":"+d.encode(a.password));b&&(b+="@");return b};d.buildQuery=function(a,b,c){var e="",f,n;for(f in a)if("__proto__"!==f&&B.call(a,f))if(A(a[f])){var z={};var I=0;for(n=a[f].length;I<n;I++)void 0!==a[f][I]&&void 0===z[a[f][I]+""]&&(e+="&"+d.buildQueryParameter(f,a[f][I],c),!0!==b&&(z[a[f][I]+
|
||||
""]=!0))}else void 0!==a[f]&&(e+="&"+d.buildQueryParameter(f,a[f],c));return e.substring(1)};d.buildQueryParameter=function(a,b,c){return d.encodeQuery(a,c)+(null!==b?"="+d.encodeQuery(b,c):"")};d.addQuery=function(a,b,c){if("object"===typeof b)for(var e in b)B.call(b,e)&&d.addQuery(a,e,b[e]);else if("string"===typeof b)void 0===a[b]?a[b]=c:("string"===typeof a[b]&&(a[b]=[a[b]]),A(c)||(c=[c]),a[b]=(a[b]||[]).concat(c));else throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");
|
||||
};d.setQuery=function(a,b,c){if("object"===typeof b)for(var e in b)B.call(b,e)&&d.setQuery(a,e,b[e]);else if("string"===typeof b)a[b]=void 0===c?null:c;else throw new TypeError("URI.setQuery() accepts an object, string as the name parameter");};d.removeQuery=function(a,b,c){var e;if(A(b))for(c=0,e=b.length;c<e;c++)a[b[c]]=void 0;else if("RegExp"===E(b))for(e in a)b.test(e)&&(a[e]=void 0);else if("object"===typeof b)for(e in b)B.call(b,e)&&d.removeQuery(a,e,b[e]);else if("string"===typeof b)void 0!==
|
||||
c?"RegExp"===E(c)?!A(a[b])&&c.test(a[b])?a[b]=void 0:a[b]=h(a[b],c):a[b]!==String(c)||A(c)&&1!==c.length?A(a[b])&&(a[b]=h(a[b],c)):a[b]=void 0:a[b]=void 0;else throw new TypeError("URI.removeQuery() accepts an object, string, RegExp as the first parameter");};d.hasQuery=function(a,b,c,e){switch(E(b)){case "String":break;case "RegExp":for(var f in a)if(B.call(a,f)&&b.test(f)&&(void 0===c||d.hasQuery(a,f,c)))return!0;return!1;case "Object":for(var n in b)if(B.call(b,n)&&!d.hasQuery(a,n,b[n]))return!1;
|
||||
return!0;default:throw new TypeError("URI.hasQuery() accepts a string, regular expression or object as the name parameter");}switch(E(c)){case "Undefined":return b in a;case "Boolean":return a=!(A(a[b])?!a[b].length:!a[b]),c===a;case "Function":return!!c(a[b],b,a);case "Array":return A(a[b])?(e?p:D)(a[b],c):!1;case "RegExp":return A(a[b])?e?p(a[b],c):!1:!(!a[b]||!a[b].match(c));case "Number":c=String(c);case "String":return A(a[b])?e?p(a[b],c):!1:a[b]===c;default:throw new TypeError("URI.hasQuery() accepts undefined, boolean, string, number, RegExp, Function as the value parameter");
|
||||
}};d.joinPaths=function(){for(var a=[],b=[],c=0,e=0;e<arguments.length;e++){var f=new d(arguments[e]);a.push(f);f=f.segment();for(var n=0;n<f.length;n++)"string"===typeof f[n]&&b.push(f[n]),f[n]&&c++}if(!b.length||!c)return new d("");b=(new d("")).segment(b);""!==a[0].path()&&"/"!==a[0].path().slice(0,1)||b.path("/"+b.path());return b.normalize()};d.commonPath=function(a,b){var c=Math.min(a.length,b.length),e;for(e=0;e<c;e++)if(a.charAt(e)!==b.charAt(e)){e--;break}if(1>e)return a.charAt(0)===b.charAt(0)&&
|
||||
"/"===a.charAt(0)?"/":"";if("/"!==a.charAt(e)||"/"!==b.charAt(e))e=a.substring(0,e).lastIndexOf("/");return a.substring(0,e+1)};d.withinString=function(a,b,c){c||(c={});var e=c.start||d.findUri.start,f=c.end||d.findUri.end,n=c.trim||d.findUri.trim,z=c.parens||d.findUri.parens,I=/[a-z0-9-]=["']?$/i;for(e.lastIndex=0;;){var L=e.exec(a);if(!L)break;var P=L.index;if(c.ignoreHtml){var N=a.slice(Math.max(P-3,0),P);if(N&&I.test(N))continue}var O=P+a.slice(P).search(f);N=a.slice(P,O);for(O=-1;;){var Q=z.exec(N);
|
||||
if(!Q)break;O=Math.max(O,Q.index+Q[0].length)}N=-1<O?N.slice(0,O)+N.slice(O).replace(n,""):N.replace(n,"");N.length<=L[0].length||c.ignore&&c.ignore.test(N)||(O=P+N.length,L=b(N,P,O,a),void 0===L?e.lastIndex=O:(L=String(L),a=a.slice(0,P)+L+a.slice(O),e.lastIndex=P+L.length))}e.lastIndex=0;return a};d.ensureValidHostname=function(a,b){var c=!!a,e=!1;b&&(e=p(d.hostProtocols,b));if(e&&!c)throw new TypeError("Hostname cannot be empty, if protocol is "+b);if(a&&a.match(d.invalid_hostname_characters)){if(!r)throw new TypeError('Hostname "'+
|
||||
a+'" contains characters other than [A-Z0-9.-:_] and Punycode.js is not available');if(r.toASCII(a).match(d.invalid_hostname_characters))throw new TypeError('Hostname "'+a+'" contains characters other than [A-Z0-9.-:_]');}};d.ensureValidPort=function(a){if(a){var b=Number(a);if(!(/^[0-9]+$/.test(b)&&0<b&&65536>b))throw new TypeError('Port "'+a+'" is not a valid port');}};d.noConflict=function(a){if(a)return a={URI:this.noConflict()},m.URITemplate&&"function"===typeof m.URITemplate.noConflict&&(a.URITemplate=
|
||||
m.URITemplate.noConflict()),m.IPv6&&"function"===typeof m.IPv6.noConflict&&(a.IPv6=m.IPv6.noConflict()),m.SecondLevelDomains&&"function"===typeof m.SecondLevelDomains.noConflict&&(a.SecondLevelDomains=m.SecondLevelDomains.noConflict()),a;m.URI===this&&(m.URI=v);return this};g.build=function(a){if(!0===a)this._deferred_build=!0;else if(void 0===a||this._deferred_build)this._string=d.build(this._parts),this._deferred_build=!1;return this};g.clone=function(){return new d(this)};g.valueOf=g.toString=
|
||||
function(){return this.build(!1)._string};g.protocol=w("protocol");g.username=w("username");g.password=w("password");g.hostname=w("hostname");g.port=w("port");g.query=H("query","?");g.fragment=H("fragment","#");g.search=function(a,b){var c=this.query(a,b);return"string"===typeof c&&c.length?"?"+c:c};g.hash=function(a,b){var c=this.fragment(a,b);return"string"===typeof c&&c.length?"#"+c:c};g.pathname=function(a,b){if(void 0===a||!0===a){var c=this._parts.path||(this._parts.hostname?"/":"");return a?
|
||||
(this._parts.urn?d.decodeUrnPath:d.decodePath)(c):c}this._parts.path=this._parts.urn?a?d.recodeUrnPath(a):"":a?d.recodePath(a):"/";this.build(!b);return this};g.path=g.pathname;g.href=function(a,b){var c;if(void 0===a)return this.toString();this._string="";this._parts=d._parts();var e=a instanceof d,f="object"===typeof a&&(a.hostname||a.path||a.pathname);a.nodeName&&(f=d.getDomAttribute(a),a=a[f]||"",f=!1);!e&&f&&void 0!==a.pathname&&(a=a.toString());if("string"===typeof a||a instanceof String)this._parts=
|
||||
d.parse(String(a),this._parts);else if(e||f){e=e?a._parts:a;for(c in e)"query"!==c&&B.call(this._parts,c)&&(this._parts[c]=e[c]);e.query&&this.query(e.query,!1)}else throw new TypeError("invalid input");this.build(!b);return this};g.is=function(a){var b=!1,c=!1,e=!1,f=!1,n=!1,z=!1,I=!1,L=!this._parts.urn;this._parts.hostname&&(L=!1,c=d.ip4_expression.test(this._parts.hostname),e=d.ip6_expression.test(this._parts.hostname),b=c||e,n=(f=!b)&&k&&k.has(this._parts.hostname),z=f&&d.idn_expression.test(this._parts.hostname),
|
||||
I=f&&d.punycode_expression.test(this._parts.hostname));switch(a.toLowerCase()){case "relative":return L;case "absolute":return!L;case "domain":case "name":return f;case "sld":return n;case "ip":return b;case "ip4":case "ipv4":case "inet4":return c;case "ip6":case "ipv6":case "inet6":return e;case "idn":return z;case "url":return!this._parts.urn;case "urn":return!!this._parts.urn;case "punycode":return I}return null};var C=g.protocol,y=g.port,J=g.hostname;g.protocol=function(a,b){if(a&&(a=a.replace(/:(\/\/)?$/,
|
||||
""),!a.match(d.protocol_expression)))throw new TypeError('Protocol "'+a+"\" contains characters other than [A-Z0-9.+-] or doesn't start with [A-Z]");return C.call(this,a,b)};g.scheme=g.protocol;g.port=function(a,b){if(this._parts.urn)return void 0===a?"":this;void 0!==a&&(0===a&&(a=null),a&&(a+="",":"===a.charAt(0)&&(a=a.substring(1)),d.ensureValidPort(a)));return y.call(this,a,b)};g.hostname=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0!==a){var c={preventInvalidHostname:this._parts.preventInvalidHostname};
|
||||
if("/"!==d.parseHost(a,c))throw new TypeError('Hostname "'+a+'" contains characters other than [A-Z0-9.-]');a=c.hostname;this._parts.preventInvalidHostname&&d.ensureValidHostname(a,this._parts.protocol)}return J.call(this,a,b)};g.origin=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){var c=this.protocol();return this.authority()?(c?c+"://":"")+this.authority():""}c=d(a);this.protocol(c.protocol()).authority(c.authority()).build(!b);return this};g.host=function(a,b){if(this._parts.urn)return void 0===
|
||||
a?"":this;if(void 0===a)return this._parts.hostname?d.buildHost(this._parts):"";if("/"!==d.parseHost(a,this._parts))throw new TypeError('Hostname "'+a+'" contains characters other than [A-Z0-9.-]');this.build(!b);return this};g.authority=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a)return this._parts.hostname?d.buildAuthority(this._parts):"";if("/"!==d.parseAuthority(a,this._parts))throw new TypeError('Hostname "'+a+'" contains characters other than [A-Z0-9.-]');this.build(!b);
|
||||
return this};g.userinfo=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){var c=d.buildUserinfo(this._parts);return c?c.substring(0,c.length-1):c}"@"!==a[a.length-1]&&(a+="@");d.parseUserinfo(a,this._parts);this.build(!b);return this};g.resource=function(a,b){if(void 0===a)return this.path()+this.search()+this.hash();var c=d.parse(a);this._parts.path=c.path;this._parts.query=c.query;this._parts.fragment=c.fragment;this.build(!b);return this};g.subdomain=function(a,b){if(this._parts.urn)return void 0===
|
||||
a?"":this;if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var c=this._parts.hostname.length-this.domain().length-1;return this._parts.hostname.substring(0,c)||""}c=this._parts.hostname.length-this.domain().length;c=this._parts.hostname.substring(0,c);c=new RegExp("^"+q(c));a&&"."!==a.charAt(a.length-1)&&(a+=".");if(-1!==a.indexOf(":"))throw new TypeError("Domains cannot contain colons");a&&d.ensureValidHostname(a,this._parts.protocol);this._parts.hostname=this._parts.hostname.replace(c,
|
||||
a);this.build(!b);return this};g.domain=function(a,b){if(this._parts.urn)return void 0===a?"":this;"boolean"===typeof a&&(b=a,a=void 0);if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var c=this._parts.hostname.match(/\./g);if(c&&2>c.length)return this._parts.hostname;c=this._parts.hostname.length-this.tld(b).length-1;c=this._parts.hostname.lastIndexOf(".",c-1)+1;return this._parts.hostname.substring(c)||""}if(!a)throw new TypeError("cannot set domain empty");if(-1!==a.indexOf(":"))throw new TypeError("Domains cannot contain colons");
|
||||
d.ensureValidHostname(a,this._parts.protocol);!this._parts.hostname||this.is("IP")?this._parts.hostname=a:(c=new RegExp(q(this.domain())+"$"),this._parts.hostname=this._parts.hostname.replace(c,a));this.build(!b);return this};g.tld=function(a,b){if(this._parts.urn)return void 0===a?"":this;"boolean"===typeof a&&(b=a,a=void 0);if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var c=this._parts.hostname.lastIndexOf(".");c=this._parts.hostname.substring(c+1);return!0!==b&&k&&k.list[c.toLowerCase()]?
|
||||
k.get(this._parts.hostname)||c:c}if(a)if(a.match(/[^a-zA-Z0-9-]/))if(k&&k.is(a))c=new RegExp(q(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(c,a);else throw new TypeError('TLD "'+a+'" contains characters other than [A-Z0-9]');else{if(!this._parts.hostname||this.is("IP"))throw new ReferenceError("cannot set TLD on non-domain host");c=new RegExp(q(this.tld())+"$");this._parts.hostname=this._parts.hostname.replace(c,a)}else throw new TypeError("cannot set TLD empty");this.build(!b);
|
||||
return this};g.directory=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path&&!this._parts.hostname)return"";if("/"===this._parts.path)return"/";var c=this._parts.path.length-this.filename().length-1;c=this._parts.path.substring(0,c)||(this._parts.hostname?"/":"");return a?d.decodePath(c):c}c=this._parts.path.length-this.filename().length;c=this._parts.path.substring(0,c);c=new RegExp("^"+q(c));this.is("relative")||(a||(a="/"),"/"!==a.charAt(0)&&
|
||||
(a="/"+a));a&&"/"!==a.charAt(a.length-1)&&(a+="/");a=d.recodePath(a);this._parts.path=this._parts.path.replace(c,a);this.build(!b);return this};g.filename=function(a,b){if(this._parts.urn)return void 0===a?"":this;if("string"!==typeof a){if(!this._parts.path||"/"===this._parts.path)return"";var c=this._parts.path.lastIndexOf("/");c=this._parts.path.substring(c+1);return a?d.decodePathSegment(c):c}c=!1;"/"===a.charAt(0)&&(a=a.substring(1));a.match(/\.?\//)&&(c=!0);var e=new RegExp(q(this.filename())+
|
||||
"$");a=d.recodePath(a);this._parts.path=this._parts.path.replace(e,a);c?this.normalizePath(b):this.build(!b);return this};g.suffix=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path||"/"===this._parts.path)return"";var c=this.filename(),e=c.lastIndexOf(".");if(-1===e)return"";c=c.substring(e+1);c=/^[a-z0-9%]+$/i.test(c)?c:"";return a?d.decodePathSegment(c):c}"."===a.charAt(0)&&(a=a.substring(1));if(c=this.suffix())e=a?new RegExp(q(c)+"$"):new RegExp(q("."+
|
||||
c)+"$");else{if(!a)return this;this._parts.path+="."+d.recodePath(a)}e&&(a=d.recodePath(a),this._parts.path=this._parts.path.replace(e,a));this.build(!b);return this};g.segment=function(a,b,c){var e=this._parts.urn?":":"/",f=this.path(),n="/"===f.substring(0,1);f=f.split(e);void 0!==a&&"number"!==typeof a&&(c=b,b=a,a=void 0);if(void 0!==a&&"number"!==typeof a)throw Error('Bad segment "'+a+'", must be 0-based integer');n&&f.shift();0>a&&(a=Math.max(f.length+a,0));if(void 0===b)return void 0===a?f:
|
||||
f[a];if(null===a||void 0===f[a])if(A(b)){f=[];a=0;for(var z=b.length;a<z;a++)if(b[a].length||f.length&&f[f.length-1].length)f.length&&!f[f.length-1].length&&f.pop(),f.push(u(b[a]))}else{if(b||"string"===typeof b)b=u(b),""===f[f.length-1]?f[f.length-1]=b:f.push(b)}else b?f[a]=u(b):f.splice(a,1);n&&f.unshift("");return this.path(f.join(e),c)};g.segmentCoded=function(a,b,c){var e;"number"!==typeof a&&(c=b,b=a,a=void 0);if(void 0===b){a=this.segment(a,b,c);if(A(a)){var f=0;for(e=a.length;f<e;f++)a[f]=
|
||||
d.decode(a[f])}else a=void 0!==a?d.decode(a):void 0;return a}if(A(b))for(f=0,e=b.length;f<e;f++)b[f]=d.encode(b[f]);else b="string"===typeof b||b instanceof String?d.encode(b):b;return this.segment(a,b,c)};var M=g.query;g.query=function(a,b){if(!0===a)return d.parseQuery(this._parts.query,this._parts.escapeQuerySpace);if("function"===typeof a){var c=d.parseQuery(this._parts.query,this._parts.escapeQuerySpace),e=a.call(this,c);this._parts.query=d.buildQuery(e||c,this._parts.duplicateQueryParameters,
|
||||
this._parts.escapeQuerySpace);this.build(!b);return this}return void 0!==a&&"string"!==typeof a?(this._parts.query=d.buildQuery(a,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),this.build(!b),this):M.call(this,a,b)};g.setQuery=function(a,b,c){var e=d.parseQuery(this._parts.query,this._parts.escapeQuerySpace);if("string"===typeof a||a instanceof String)e[a]=void 0!==b?b:null;else if("object"===typeof a)for(var f in a)B.call(a,f)&&(e[f]=a[f]);else throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");
|
||||
this._parts.query=d.buildQuery(e,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace);"string"!==typeof a&&(c=b);this.build(!c);return this};g.addQuery=function(a,b,c){var e=d.parseQuery(this._parts.query,this._parts.escapeQuerySpace);d.addQuery(e,a,void 0===b?null:b);this._parts.query=d.buildQuery(e,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace);"string"!==typeof a&&(c=b);this.build(!c);return this};g.removeQuery=function(a,b,c){var e=d.parseQuery(this._parts.query,
|
||||
this._parts.escapeQuerySpace);d.removeQuery(e,a,b);this._parts.query=d.buildQuery(e,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace);"string"!==typeof a&&(c=b);this.build(!c);return this};g.hasQuery=function(a,b,c){var e=d.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return d.hasQuery(e,a,b,c)};g.setSearch=g.setQuery;g.addSearch=g.addQuery;g.removeSearch=g.removeQuery;g.hasSearch=g.hasQuery;g.normalize=function(){return this._parts.urn?this.normalizeProtocol(!1).normalizePath(!1).normalizeQuery(!1).normalizeFragment(!1).build():
|
||||
this.normalizeProtocol(!1).normalizeHostname(!1).normalizePort(!1).normalizePath(!1).normalizeQuery(!1).normalizeFragment(!1).build()};g.normalizeProtocol=function(a){"string"===typeof this._parts.protocol&&(this._parts.protocol=this._parts.protocol.toLowerCase(),this.build(!a));return this};g.normalizeHostname=function(a){this._parts.hostname&&(this.is("IDN")&&r?this._parts.hostname=r.toASCII(this._parts.hostname):this.is("IPv6")&&x&&(this._parts.hostname=x.best(this._parts.hostname)),this._parts.hostname=
|
||||
this._parts.hostname.toLowerCase(),this.build(!a));return this};g.normalizePort=function(a){"string"===typeof this._parts.protocol&&this._parts.port===d.defaultPorts[this._parts.protocol]&&(this._parts.port=null,this.build(!a));return this};g.normalizePath=function(a){var b=this._parts.path;if(!b)return this;if(this._parts.urn)return this._parts.path=d.recodeUrnPath(this._parts.path),this.build(!a),this;if("/"===this._parts.path)return this;b=d.recodePath(b);var c="";if("/"!==b.charAt(0)){var e=!0;
|
||||
b="/"+b}if("/.."===b.slice(-3)||"/."===b.slice(-2))b+="/";b=b.replace(/(\/(\.\/)+)|(\/\.$)/g,"/").replace(/\/{2,}/g,"/");e&&(c=b.substring(1).match(/^(\.\.\/)+/)||"")&&(c=c[0]);for(;;){var f=b.search(/\/\.\.(\/|$)/);if(-1===f)break;else if(0===f){b=b.substring(3);continue}var n=b.substring(0,f).lastIndexOf("/");-1===n&&(n=f);b=b.substring(0,n)+b.substring(f+3)}e&&this.is("relative")&&(b=c+b.substring(1));this._parts.path=b;this.build(!a);return this};g.normalizePathname=g.normalizePath;g.normalizeQuery=
|
||||
function(a){"string"===typeof this._parts.query&&(this._parts.query.length?this.query(d.parseQuery(this._parts.query,this._parts.escapeQuerySpace)):this._parts.query=null,this.build(!a));return this};g.normalizeFragment=function(a){this._parts.fragment||(this._parts.fragment=null,this.build(!a));return this};g.normalizeSearch=g.normalizeQuery;g.normalizeHash=g.normalizeFragment;g.iso8859=function(){var a=d.encode,b=d.decode;d.encode=escape;d.decode=decodeURIComponent;try{this.normalize()}finally{d.encode=
|
||||
a,d.decode=b}return this};g.unicode=function(){var a=d.encode,b=d.decode;d.encode=F;d.decode=unescape;try{this.normalize()}finally{d.encode=a,d.decode=b}return this};g.readable=function(){var a=this.clone();a.username("").password("").normalize();var b="";a._parts.protocol&&(b+=a._parts.protocol+"://");a._parts.hostname&&(a.is("punycode")&&r?(b+=r.toUnicode(a._parts.hostname),a._parts.port&&(b+=":"+a._parts.port)):b+=a.host());a._parts.hostname&&a._parts.path&&"/"!==a._parts.path.charAt(0)&&(b+="/");
|
||||
b+=a.path(!0);if(a._parts.query){for(var c="",e=0,f=a._parts.query.split("&"),n=f.length;e<n;e++){var z=(f[e]||"").split("=");c+="&"+d.decodeQuery(z[0],this._parts.escapeQuerySpace).replace(/&/g,"%26");void 0!==z[1]&&(c+="="+d.decodeQuery(z[1],this._parts.escapeQuerySpace).replace(/&/g,"%26"))}b+="?"+c.substring(1)}return b+=d.decodeQuery(a.hash(),!0)};g.absoluteTo=function(a){var b=this.clone(),c=["protocol","username","password","hostname","port"],e,f;if(this._parts.urn)throw Error("URNs do not have any generally defined hierarchical components");
|
||||
a instanceof d||(a=new d(a));if(b._parts.protocol)return b;b._parts.protocol=a._parts.protocol;if(this._parts.hostname)return b;for(e=0;f=c[e];e++)b._parts[f]=a._parts[f];b._parts.path?(".."===b._parts.path.substring(-2)&&(b._parts.path+="/"),"/"!==b.path().charAt(0)&&(c=(c=a.directory())?c:0===a.path().indexOf("/")?"/":"",b._parts.path=(c?c+"/":"")+b._parts.path,b.normalizePath())):(b._parts.path=a._parts.path,b._parts.query||(b._parts.query=a._parts.query));b.build();return b};g.relativeTo=function(a){var b=
|
||||
this.clone().normalize();if(b._parts.urn)throw Error("URNs do not have any generally defined hierarchical components");a=(new d(a)).normalize();var c=b._parts;var e=a._parts;var f=b.path();a=a.path();if("/"!==f.charAt(0))throw Error("URI is already relative");if("/"!==a.charAt(0))throw Error("Cannot calculate a URI relative to another relative URI");c.protocol===e.protocol&&(c.protocol=null);if(c.username===e.username&&c.password===e.password&&null===c.protocol&&null===c.username&&null===c.password&&
|
||||
c.hostname===e.hostname&&c.port===e.port)c.hostname=null,c.port=null;else return b.build();if(f===a)return c.path="",b.build();f=d.commonPath(f,a);if(!f)return b.build();e=e.path.substring(f.length).replace(/[^\/]*$/,"").replace(/.*?\//g,"../");c.path=e+c.path.substring(f.length)||"./";return b.build()};g.equals=function(a){var b=this.clone(),c=new d(a);a={};var e;b.normalize();c.normalize();if(b.toString()===c.toString())return!0;var f=b.query();var n=c.query();b.query("");c.query("");if(b.toString()!==
|
||||
c.toString()||f.length!==n.length)return!1;b=d.parseQuery(f,this._parts.escapeQuerySpace);n=d.parseQuery(n,this._parts.escapeQuerySpace);for(e in b)if(B.call(b,e)){if(!A(b[e])){if(b[e]!==n[e])return!1}else if(!D(b[e],n[e]))return!1;a[e]=!0}for(e in n)if(B.call(n,e)&&!a[e])return!1;return!0};g.preventInvalidHostname=function(a){this._parts.preventInvalidHostname=!!a;return this};g.duplicateQueryParameters=function(a){this._parts.duplicateQueryParameters=!!a;return this};g.escapeQuerySpace=function(a){this._parts.escapeQuerySpace=
|
||||
!!a;return this};return d});
|
||||
(function(r,x){"object"===typeof module&&module.exports?module.exports=x(require("./URI")):"function"===typeof define&&define.amd?define(["./URI"],x):r.URITemplate=x(r.URI,r)})(this,function(r,x){function k(h){if(k._cache[h])return k._cache[h];if(!(this instanceof k))return new k(h);this.expression=h;k._cache[h]=this;return this}function m(h){this.data=h;this.cache={}}var d=x&&x.URITemplate,q=Object.prototype.hasOwnProperty,E=k.prototype,A={"":{prefix:"",separator:",",named:!1,empty_name_separator:!1,
|
||||
encode:"encode"},"+":{prefix:"",separator:",",named:!1,empty_name_separator:!1,encode:"encodeReserved"},"#":{prefix:"#",separator:",",named:!1,empty_name_separator:!1,encode:"encodeReserved"},".":{prefix:".",separator:".",named:!1,empty_name_separator:!1,encode:"encode"},"/":{prefix:"/",separator:"/",named:!1,empty_name_separator:!1,encode:"encode"},";":{prefix:";",separator:";",named:!0,empty_name_separator:!1,encode:"encode"},"?":{prefix:"?",separator:"&",named:!0,empty_name_separator:!0,encode:"encode"},
|
||||
"&":{prefix:"&",separator:"&",named:!0,empty_name_separator:!0,encode:"encode"}};k._cache={};k.EXPRESSION_PATTERN=/\{([^a-zA-Z0-9%_]?)([^\}]+)(\}|$)/g;k.VARIABLE_PATTERN=/^([^*:.](?:\.?[^*:.])*)((\*)|:(\d+))?$/;k.VARIABLE_NAME_PATTERN=/[^a-zA-Z0-9%_.]/;k.LITERAL_PATTERN=/[<>{}"`^| \\]/;k.expand=function(h,p,D){var u=A[h.operator],K=u.named?"Named":"Unnamed";h=h.variables;var F=[],w,H;for(H=0;w=h[H];H++){var v=p.get(w.name);if(0===v.type&&D&&D.strict)throw Error('Missing expansion value for variable "'+
|
||||
w.name+'"');if(v.val.length){if(1<v.type&&w.maxlength)throw Error('Invalid expression: Prefix modifier not applicable to variable "'+w.name+'"');F.push(k["expand"+K](v,u,w.explode,w.explode&&u.separator||",",w.maxlength,w.name))}else v.type&&F.push("")}return F.length?u.prefix+F.join(u.separator):""};k.expandNamed=function(h,p,D,u,K,F){var w="",H=p.encode;p=p.empty_name_separator;var v=!h[H].length,g=2===h.type?"":r[H](F),B;var G=0;for(B=h.val.length;G<B;G++){if(K){var l=r[H](h.val[G][1].substring(0,
|
||||
K));2===h.type&&(g=r[H](h.val[G][0].substring(0,K)))}else v?(l=r[H](h.val[G][1]),2===h.type?(g=r[H](h.val[G][0]),h[H].push([g,l])):h[H].push([void 0,l])):(l=h[H][G][1],2===h.type&&(g=h[H][G][0]));w&&(w+=u);D?w+=g+(p||l?"=":"")+l:(G||(w+=r[H](F)+(p||l?"=":"")),2===h.type&&(w+=g+","),w+=l)}return w};k.expandUnnamed=function(h,p,D,u,K){var F="",w=p.encode;p=p.empty_name_separator;var H=!h[w].length,v;var g=0;for(v=h.val.length;g<v;g++){if(K)var B=r[w](h.val[g][1].substring(0,K));else H?(B=r[w](h.val[g][1]),
|
||||
h[w].push([2===h.type?r[w](h.val[g][0]):void 0,B])):B=h[w][g][1];F&&(F+=u);if(2===h.type){var G=K?r[w](h.val[g][0].substring(0,K)):h[w][g][0];F+=G;F=D?F+(p||B?"=":""):F+","}F+=B}return F};k.noConflict=function(){x.URITemplate===k&&(x.URITemplate=d);return k};E.expand=function(h,p){var D="";this.parts&&this.parts.length||this.parse();h instanceof m||(h=new m(h));for(var u=0,K=this.parts.length;u<K;u++)D+="string"===typeof this.parts[u]?this.parts[u]:k.expand(this.parts[u],h,p);return D};E.parse=function(){var h=
|
||||
this.expression,p=k.EXPRESSION_PATTERN,D=k.VARIABLE_PATTERN,u=k.VARIABLE_NAME_PATTERN,K=k.LITERAL_PATTERN,F=[],w=0,H=function(t){if(t.match(K))throw Error('Invalid Literal "'+t+'"');return t};for(p.lastIndex=0;;){var v=p.exec(h);if(null===v){F.push(H(h.substring(w)));break}else F.push(H(h.substring(w,v.index))),w=v.index+v[0].length;if(!A[v[1]])throw Error('Unknown Operator "'+v[1]+'" in "'+v[0]+'"');if(!v[3])throw Error('Unclosed Expression "'+v[0]+'"');var g=v[2].split(",");for(var B=0,G=g.length;B<
|
||||
G;B++){var l=g[B].match(D);if(null===l)throw Error('Invalid Variable "'+g[B]+'" in "'+v[0]+'"');if(l[1].match(u))throw Error('Invalid Variable Name "'+l[1]+'" in "'+v[0]+'"');g[B]={name:l[1],explode:!!l[3],maxlength:l[4]&&parseInt(l[4],10)}}if(!g.length)throw Error('Expression Missing Variable(s) "'+v[0]+'"');F.push({expression:v[0],operator:v[1],variables:g})}F.length||F.push(H(h));this.parts=F;return this};m.prototype.get=function(h){var p=this.data,D={type:0,val:[],encode:[],encodeReserved:[]};
|
||||
if(void 0!==this.cache[h])return this.cache[h];this.cache[h]=D;p="[object Function]"===String(Object.prototype.toString.call(p))?p(h):"[object Function]"===String(Object.prototype.toString.call(p[h]))?p[h](h):p[h];if(void 0!==p&&null!==p)if("[object Array]"===String(Object.prototype.toString.call(p))){var u=0;for(h=p.length;u<h;u++)void 0!==p[u]&&null!==p[u]&&D.val.push([void 0,String(p[u])]);D.val.length&&(D.type=3)}else if("[object Object]"===String(Object.prototype.toString.call(p))){for(u in p)q.call(p,
|
||||
u)&&void 0!==p[u]&&null!==p[u]&&D.val.push([u,String(p[u])]);D.val.length&&(D.type=2)}else D.type=1,D.val.push([void 0,String(p)]);return D};r.expand=function(h,p){var D=(new k(h)).expand(p);return new r(D)};return k});
|
||||
516
book/node_modules/urijs/src/URITemplate.js
generated
vendored
Normal file
516
book/node_modules/urijs/src/URITemplate.js
generated
vendored
Normal file
@@ -0,0 +1,516 @@
|
||||
/*!
|
||||
* URI.js - Mutating URLs
|
||||
* URI Template Support - http://tools.ietf.org/html/rfc6570
|
||||
*
|
||||
* Version: 1.19.11
|
||||
*
|
||||
* Author: Rodney Rehm
|
||||
* Web: http://medialize.github.io/URI.js/
|
||||
*
|
||||
* Licensed under
|
||||
* MIT License http://www.opensource.org/licenses/mit-license
|
||||
*
|
||||
*/
|
||||
(function (root, factory) {
|
||||
'use strict';
|
||||
// https://github.com/umdjs/umd/blob/master/returnExports.js
|
||||
if (typeof module === 'object' && module.exports) {
|
||||
// Node
|
||||
module.exports = factory(require('./URI'));
|
||||
} else if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define(['./URI'], factory);
|
||||
} else {
|
||||
// Browser globals (root is window)
|
||||
root.URITemplate = factory(root.URI, root);
|
||||
}
|
||||
}(this, function (URI, root) {
|
||||
'use strict';
|
||||
// FIXME: v2.0.0 renamce non-camelCase properties to uppercase
|
||||
/*jshint camelcase: false */
|
||||
|
||||
// save current URITemplate variable, if any
|
||||
var _URITemplate = root && root.URITemplate;
|
||||
|
||||
var hasOwn = Object.prototype.hasOwnProperty;
|
||||
function URITemplate(expression) {
|
||||
// serve from cache where possible
|
||||
if (URITemplate._cache[expression]) {
|
||||
return URITemplate._cache[expression];
|
||||
}
|
||||
|
||||
// Allow instantiation without the 'new' keyword
|
||||
if (!(this instanceof URITemplate)) {
|
||||
return new URITemplate(expression);
|
||||
}
|
||||
|
||||
this.expression = expression;
|
||||
URITemplate._cache[expression] = this;
|
||||
return this;
|
||||
}
|
||||
|
||||
function Data(data) {
|
||||
this.data = data;
|
||||
this.cache = {};
|
||||
}
|
||||
|
||||
var p = URITemplate.prototype;
|
||||
// list of operators and their defined options
|
||||
var operators = {
|
||||
// Simple string expansion
|
||||
'' : {
|
||||
prefix: '',
|
||||
separator: ',',
|
||||
named: false,
|
||||
empty_name_separator: false,
|
||||
encode : 'encode'
|
||||
},
|
||||
// Reserved character strings
|
||||
'+' : {
|
||||
prefix: '',
|
||||
separator: ',',
|
||||
named: false,
|
||||
empty_name_separator: false,
|
||||
encode : 'encodeReserved'
|
||||
},
|
||||
// Fragment identifiers prefixed by '#'
|
||||
'#' : {
|
||||
prefix: '#',
|
||||
separator: ',',
|
||||
named: false,
|
||||
empty_name_separator: false,
|
||||
encode : 'encodeReserved'
|
||||
},
|
||||
// Name labels or extensions prefixed by '.'
|
||||
'.' : {
|
||||
prefix: '.',
|
||||
separator: '.',
|
||||
named: false,
|
||||
empty_name_separator: false,
|
||||
encode : 'encode'
|
||||
},
|
||||
// Path segments prefixed by '/'
|
||||
'/' : {
|
||||
prefix: '/',
|
||||
separator: '/',
|
||||
named: false,
|
||||
empty_name_separator: false,
|
||||
encode : 'encode'
|
||||
},
|
||||
// Path parameter name or name=value pairs prefixed by ';'
|
||||
';' : {
|
||||
prefix: ';',
|
||||
separator: ';',
|
||||
named: true,
|
||||
empty_name_separator: false,
|
||||
encode : 'encode'
|
||||
},
|
||||
// Query component beginning with '?' and consisting
|
||||
// of name=value pairs separated by '&'; an
|
||||
'?' : {
|
||||
prefix: '?',
|
||||
separator: '&',
|
||||
named: true,
|
||||
empty_name_separator: true,
|
||||
encode : 'encode'
|
||||
},
|
||||
// Continuation of query-style &name=value pairs
|
||||
// within a literal query component.
|
||||
'&' : {
|
||||
prefix: '&',
|
||||
separator: '&',
|
||||
named: true,
|
||||
empty_name_separator: true,
|
||||
encode : 'encode'
|
||||
}
|
||||
|
||||
// The operator characters equals ("="), comma (","), exclamation ("!"),
|
||||
// at sign ("@"), and pipe ("|") are reserved for future extensions.
|
||||
};
|
||||
|
||||
// storage for already parsed templates
|
||||
URITemplate._cache = {};
|
||||
// pattern to identify expressions [operator, variable-list] in template
|
||||
URITemplate.EXPRESSION_PATTERN = /\{([^a-zA-Z0-9%_]?)([^\}]+)(\}|$)/g;
|
||||
// pattern to identify variables [name, explode, maxlength] in variable-list
|
||||
URITemplate.VARIABLE_PATTERN = /^([^*:.](?:\.?[^*:.])*)((\*)|:(\d+))?$/;
|
||||
// pattern to verify variable name integrity
|
||||
URITemplate.VARIABLE_NAME_PATTERN = /[^a-zA-Z0-9%_.]/;
|
||||
// pattern to verify literal integrity
|
||||
URITemplate.LITERAL_PATTERN = /[<>{}"`^| \\]/;
|
||||
|
||||
// expand parsed expression (expression, not template!)
|
||||
URITemplate.expand = function(expression, data, opts) {
|
||||
// container for defined options for the given operator
|
||||
var options = operators[expression.operator];
|
||||
// expansion type (include keys or not)
|
||||
var type = options.named ? 'Named' : 'Unnamed';
|
||||
// list of variables within the expression
|
||||
var variables = expression.variables;
|
||||
// result buffer for evaluating the expression
|
||||
var buffer = [];
|
||||
var d, variable, i;
|
||||
|
||||
for (i = 0; (variable = variables[i]); i++) {
|
||||
// fetch simplified data source
|
||||
d = data.get(variable.name);
|
||||
if (d.type === 0 && opts && opts.strict) {
|
||||
throw new Error('Missing expansion value for variable "' + variable.name + '"');
|
||||
}
|
||||
if (!d.val.length) {
|
||||
if (d.type) {
|
||||
// empty variables (empty string)
|
||||
// still lead to a separator being appended!
|
||||
buffer.push('');
|
||||
}
|
||||
// no data, no action
|
||||
continue;
|
||||
}
|
||||
|
||||
if (d.type > 1 && variable.maxlength) {
|
||||
// composite variable cannot specify maxlength
|
||||
throw new Error('Invalid expression: Prefix modifier not applicable to variable "' + variable.name + '"');
|
||||
}
|
||||
|
||||
// expand the given variable
|
||||
buffer.push(URITemplate['expand' + type](
|
||||
d,
|
||||
options,
|
||||
variable.explode,
|
||||
variable.explode && options.separator || ',',
|
||||
variable.maxlength,
|
||||
variable.name
|
||||
));
|
||||
}
|
||||
|
||||
if (buffer.length) {
|
||||
return options.prefix + buffer.join(options.separator);
|
||||
} else {
|
||||
// prefix is not prepended for empty expressions
|
||||
return '';
|
||||
}
|
||||
};
|
||||
// expand a named variable
|
||||
URITemplate.expandNamed = function(d, options, explode, separator, length, name) {
|
||||
// variable result buffer
|
||||
var result = '';
|
||||
// peformance crap
|
||||
var encode = options.encode;
|
||||
var empty_name_separator = options.empty_name_separator;
|
||||
// flag noting if values are already encoded
|
||||
var _encode = !d[encode].length;
|
||||
// key for named expansion
|
||||
var _name = d.type === 2 ? '': URI[encode](name);
|
||||
var _value, i, l;
|
||||
|
||||
// for each found value
|
||||
for (i = 0, l = d.val.length; i < l; i++) {
|
||||
if (length) {
|
||||
// maxlength must be determined before encoding can happen
|
||||
_value = URI[encode](d.val[i][1].substring(0, length));
|
||||
if (d.type === 2) {
|
||||
// apply maxlength to keys of objects as well
|
||||
_name = URI[encode](d.val[i][0].substring(0, length));
|
||||
}
|
||||
} else if (_encode) {
|
||||
// encode value
|
||||
_value = URI[encode](d.val[i][1]);
|
||||
if (d.type === 2) {
|
||||
// encode name and cache encoded value
|
||||
_name = URI[encode](d.val[i][0]);
|
||||
d[encode].push([_name, _value]);
|
||||
} else {
|
||||
// cache encoded value
|
||||
d[encode].push([undefined, _value]);
|
||||
}
|
||||
} else {
|
||||
// values are already encoded and can be pulled from cache
|
||||
_value = d[encode][i][1];
|
||||
if (d.type === 2) {
|
||||
_name = d[encode][i][0];
|
||||
}
|
||||
}
|
||||
|
||||
if (result) {
|
||||
// unless we're the first value, prepend the separator
|
||||
result += separator;
|
||||
}
|
||||
|
||||
if (!explode) {
|
||||
if (!i) {
|
||||
// first element, so prepend variable name
|
||||
result += URI[encode](name) + (empty_name_separator || _value ? '=' : '');
|
||||
}
|
||||
|
||||
if (d.type === 2) {
|
||||
// without explode-modifier, keys of objects are returned comma-separated
|
||||
result += _name + ',';
|
||||
}
|
||||
|
||||
result += _value;
|
||||
} else {
|
||||
// only add the = if it is either default (?&) or there actually is a value (;)
|
||||
result += _name + (empty_name_separator || _value ? '=' : '') + _value;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
// expand an unnamed variable
|
||||
URITemplate.expandUnnamed = function(d, options, explode, separator, length) {
|
||||
// variable result buffer
|
||||
var result = '';
|
||||
// performance crap
|
||||
var encode = options.encode;
|
||||
var empty_name_separator = options.empty_name_separator;
|
||||
// flag noting if values are already encoded
|
||||
var _encode = !d[encode].length;
|
||||
var _name, _value, i, l;
|
||||
|
||||
// for each found value
|
||||
for (i = 0, l = d.val.length; i < l; i++) {
|
||||
if (length) {
|
||||
// maxlength must be determined before encoding can happen
|
||||
_value = URI[encode](d.val[i][1].substring(0, length));
|
||||
} else if (_encode) {
|
||||
// encode and cache value
|
||||
_value = URI[encode](d.val[i][1]);
|
||||
d[encode].push([
|
||||
d.type === 2 ? URI[encode](d.val[i][0]) : undefined,
|
||||
_value
|
||||
]);
|
||||
} else {
|
||||
// value already encoded, pull from cache
|
||||
_value = d[encode][i][1];
|
||||
}
|
||||
|
||||
if (result) {
|
||||
// unless we're the first value, prepend the separator
|
||||
result += separator;
|
||||
}
|
||||
|
||||
if (d.type === 2) {
|
||||
if (length) {
|
||||
// maxlength also applies to keys of objects
|
||||
_name = URI[encode](d.val[i][0].substring(0, length));
|
||||
} else {
|
||||
// at this point the name must already be encoded
|
||||
_name = d[encode][i][0];
|
||||
}
|
||||
|
||||
result += _name;
|
||||
if (explode) {
|
||||
// explode-modifier separates name and value by "="
|
||||
result += (empty_name_separator || _value ? '=' : '');
|
||||
} else {
|
||||
// no explode-modifier separates name and value by ","
|
||||
result += ',';
|
||||
}
|
||||
}
|
||||
|
||||
result += _value;
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
URITemplate.noConflict = function() {
|
||||
if (root.URITemplate === URITemplate) {
|
||||
root.URITemplate = _URITemplate;
|
||||
}
|
||||
|
||||
return URITemplate;
|
||||
};
|
||||
|
||||
// expand template through given data map
|
||||
p.expand = function(data, opts) {
|
||||
var result = '';
|
||||
|
||||
if (!this.parts || !this.parts.length) {
|
||||
// lazilyy parse the template
|
||||
this.parse();
|
||||
}
|
||||
|
||||
if (!(data instanceof Data)) {
|
||||
// make given data available through the
|
||||
// optimized data handling thingie
|
||||
data = new Data(data);
|
||||
}
|
||||
|
||||
for (var i = 0, l = this.parts.length; i < l; i++) {
|
||||
/*jshint laxbreak: true */
|
||||
result += typeof this.parts[i] === 'string'
|
||||
// literal string
|
||||
? this.parts[i]
|
||||
// expression
|
||||
: URITemplate.expand(this.parts[i], data, opts);
|
||||
/*jshint laxbreak: false */
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
// parse template into action tokens
|
||||
p.parse = function() {
|
||||
// performance crap
|
||||
var expression = this.expression;
|
||||
var ePattern = URITemplate.EXPRESSION_PATTERN;
|
||||
var vPattern = URITemplate.VARIABLE_PATTERN;
|
||||
var nPattern = URITemplate.VARIABLE_NAME_PATTERN;
|
||||
var lPattern = URITemplate.LITERAL_PATTERN;
|
||||
// token result buffer
|
||||
var parts = [];
|
||||
// position within source template
|
||||
var pos = 0;
|
||||
var variables, eMatch, vMatch;
|
||||
|
||||
var checkLiteral = function(literal) {
|
||||
if (literal.match(lPattern)) {
|
||||
throw new Error('Invalid Literal "' + literal + '"');
|
||||
}
|
||||
return literal;
|
||||
};
|
||||
|
||||
// RegExp is shared accross all templates,
|
||||
// which requires a manual reset
|
||||
ePattern.lastIndex = 0;
|
||||
// I don't like while(foo = bar()) loops,
|
||||
// to make things simpler I go while(true) and break when required
|
||||
while (true) {
|
||||
eMatch = ePattern.exec(expression);
|
||||
if (eMatch === null) {
|
||||
// push trailing literal
|
||||
parts.push(checkLiteral(expression.substring(pos)));
|
||||
break;
|
||||
} else {
|
||||
// push leading literal
|
||||
parts.push(checkLiteral(expression.substring(pos, eMatch.index)));
|
||||
pos = eMatch.index + eMatch[0].length;
|
||||
}
|
||||
|
||||
if (!operators[eMatch[1]]) {
|
||||
throw new Error('Unknown Operator "' + eMatch[1] + '" in "' + eMatch[0] + '"');
|
||||
} else if (!eMatch[3]) {
|
||||
throw new Error('Unclosed Expression "' + eMatch[0] + '"');
|
||||
}
|
||||
|
||||
// parse variable-list
|
||||
variables = eMatch[2].split(',');
|
||||
for (var i = 0, l = variables.length; i < l; i++) {
|
||||
vMatch = variables[i].match(vPattern);
|
||||
if (vMatch === null) {
|
||||
throw new Error('Invalid Variable "' + variables[i] + '" in "' + eMatch[0] + '"');
|
||||
} else if (vMatch[1].match(nPattern)) {
|
||||
throw new Error('Invalid Variable Name "' + vMatch[1] + '" in "' + eMatch[0] + '"');
|
||||
}
|
||||
|
||||
variables[i] = {
|
||||
name: vMatch[1],
|
||||
explode: !!vMatch[3],
|
||||
maxlength: vMatch[4] && parseInt(vMatch[4], 10)
|
||||
};
|
||||
}
|
||||
|
||||
if (!variables.length) {
|
||||
throw new Error('Expression Missing Variable(s) "' + eMatch[0] + '"');
|
||||
}
|
||||
|
||||
parts.push({
|
||||
expression: eMatch[0],
|
||||
operator: eMatch[1],
|
||||
variables: variables
|
||||
});
|
||||
}
|
||||
|
||||
if (!parts.length) {
|
||||
// template doesn't contain any expressions
|
||||
// so it is a simple literal string
|
||||
// this probably should fire a warning or something?
|
||||
parts.push(checkLiteral(expression));
|
||||
}
|
||||
|
||||
this.parts = parts;
|
||||
return this;
|
||||
};
|
||||
|
||||
// simplify data structures
|
||||
Data.prototype.get = function(key) {
|
||||
// performance crap
|
||||
var data = this.data;
|
||||
// cache for processed data-point
|
||||
var d = {
|
||||
// type of data 0: undefined/null, 1: string, 2: object, 3: array
|
||||
type: 0,
|
||||
// original values (except undefined/null)
|
||||
val: [],
|
||||
// cache for encoded values (only for non-maxlength expansion)
|
||||
encode: [],
|
||||
encodeReserved: []
|
||||
};
|
||||
var i, l, value;
|
||||
|
||||
if (this.cache[key] !== undefined) {
|
||||
// we've already processed this key
|
||||
return this.cache[key];
|
||||
}
|
||||
|
||||
this.cache[key] = d;
|
||||
|
||||
if (String(Object.prototype.toString.call(data)) === '[object Function]') {
|
||||
// data itself is a callback (global callback)
|
||||
value = data(key);
|
||||
} else if (String(Object.prototype.toString.call(data[key])) === '[object Function]') {
|
||||
// data is a map of callbacks (local callback)
|
||||
value = data[key](key);
|
||||
} else {
|
||||
// data is a map of data
|
||||
value = data[key];
|
||||
}
|
||||
|
||||
// generalize input into [ [name1, value1], [name2, value2], … ]
|
||||
// so expansion has to deal with a single data structure only
|
||||
if (value === undefined || value === null) {
|
||||
// undefined and null values are to be ignored completely
|
||||
return d;
|
||||
} else if (String(Object.prototype.toString.call(value)) === '[object Array]') {
|
||||
for (i = 0, l = value.length; i < l; i++) {
|
||||
if (value[i] !== undefined && value[i] !== null) {
|
||||
// arrays don't have names
|
||||
d.val.push([undefined, String(value[i])]);
|
||||
}
|
||||
}
|
||||
|
||||
if (d.val.length) {
|
||||
// only treat non-empty arrays as arrays
|
||||
d.type = 3; // array
|
||||
}
|
||||
} else if (String(Object.prototype.toString.call(value)) === '[object Object]') {
|
||||
for (i in value) {
|
||||
if (hasOwn.call(value, i) && value[i] !== undefined && value[i] !== null) {
|
||||
// objects have keys, remember them for named expansion
|
||||
d.val.push([i, String(value[i])]);
|
||||
}
|
||||
}
|
||||
|
||||
if (d.val.length) {
|
||||
// only treat non-empty objects as objects
|
||||
d.type = 2; // object
|
||||
}
|
||||
} else {
|
||||
d.type = 1; // primitive string (could've been string, number, boolean and objects with a toString())
|
||||
// arrays don't have names
|
||||
d.val.push([undefined, String(value)]);
|
||||
}
|
||||
|
||||
return d;
|
||||
};
|
||||
|
||||
// hook into URI for fluid access
|
||||
URI.expand = function(expression, data) {
|
||||
var template = new URITemplate(expression);
|
||||
var expansion = template.expand(data);
|
||||
|
||||
return new URI(expansion);
|
||||
};
|
||||
|
||||
return URITemplate;
|
||||
}));
|
||||
234
book/node_modules/urijs/src/jquery.URI.js
generated
vendored
Normal file
234
book/node_modules/urijs/src/jquery.URI.js
generated
vendored
Normal file
@@ -0,0 +1,234 @@
|
||||
/*!
|
||||
* URI.js - Mutating URLs
|
||||
* jQuery Plugin
|
||||
*
|
||||
* Version: 1.19.11
|
||||
*
|
||||
* Author: Rodney Rehm
|
||||
* Web: http://medialize.github.io/URI.js/jquery-uri-plugin.html
|
||||
*
|
||||
* Licensed under
|
||||
* MIT License http://www.opensource.org/licenses/mit-license
|
||||
*
|
||||
*/
|
||||
(function (root, factory) {
|
||||
'use strict';
|
||||
// https://github.com/umdjs/umd/blob/master/returnExports.js
|
||||
if (typeof module === 'object' && module.exports) {
|
||||
// Node
|
||||
module.exports = factory(require('jquery'), require('./URI'));
|
||||
} else if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define(['jquery', './URI'], factory);
|
||||
} else {
|
||||
// Browser globals (root is window)
|
||||
factory(root.jQuery, root.URI);
|
||||
}
|
||||
}(this, function ($, URI) {
|
||||
'use strict';
|
||||
// FIXME: v2.0.0 renamce non-camelCase properties to uppercase
|
||||
/*jshint camelcase: false */
|
||||
|
||||
var comparable = {};
|
||||
var compare = {
|
||||
// equals
|
||||
'=': function(value, target) {
|
||||
return value === target;
|
||||
},
|
||||
// ~= translates to value.match((?:^|\s)target(?:\s|$)) which is useless for URIs
|
||||
// |= translates to value.match((?:\b)target(?:-|\s|$)) which is useless for URIs
|
||||
// begins with
|
||||
'^=': function(value, target) {
|
||||
return !!(value + '').match(new RegExp('^' + escapeRegEx(target), 'i'));
|
||||
},
|
||||
// ends with
|
||||
'$=': function(value, target) {
|
||||
return !!(value + '').match(new RegExp(escapeRegEx(target) + '$', 'i'));
|
||||
},
|
||||
// contains
|
||||
'*=': function(value, target, property) {
|
||||
if (property === 'directory') {
|
||||
// add trailing slash so /dir/ will match the deep-end as well
|
||||
value += '/';
|
||||
}
|
||||
|
||||
return !!(value + '').match(new RegExp(escapeRegEx(target), 'i'));
|
||||
},
|
||||
'equals:': function(uri, target) {
|
||||
return uri.equals(target);
|
||||
},
|
||||
'is:': function(uri, target) {
|
||||
return uri.is(target);
|
||||
}
|
||||
};
|
||||
|
||||
function escapeRegEx(string) {
|
||||
// https://github.com/medialize/URI.js/commit/85ac21783c11f8ccab06106dba9735a31a86924d#commitcomment-821963
|
||||
return string.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
|
||||
}
|
||||
|
||||
function getUriProperty(elem) {
|
||||
var nodeName = elem.nodeName.toLowerCase();
|
||||
var property = URI.domAttributes[nodeName];
|
||||
if (nodeName === 'input' && elem.type !== 'image') {
|
||||
// compensate ambiguous <input> that is not an image
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// NOTE: as we use a static mapping from element to attribute,
|
||||
// the HTML5 attribute issue should not come up again
|
||||
// https://github.com/medialize/URI.js/issues/69
|
||||
return property;
|
||||
}
|
||||
|
||||
function generateAccessor(property) {
|
||||
return {
|
||||
get: function(elem) {
|
||||
return $(elem).uri()[property]();
|
||||
},
|
||||
set: function(elem, value) {
|
||||
$(elem).uri()[property](value);
|
||||
return value;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// populate lookup table and register $.attr('uri:accessor') handlers
|
||||
$.each('origin authority directory domain filename fragment hash host hostname href password path pathname port protocol query resource scheme search subdomain suffix tld username'.split(' '), function(k, v) {
|
||||
comparable[v] = true;
|
||||
$.attrHooks['uri:' + v] = generateAccessor(v);
|
||||
});
|
||||
|
||||
// pipe $.attr('src') and $.attr('href') through URI.js
|
||||
var _attrHooks = {
|
||||
get: function(elem) {
|
||||
return $(elem).uri();
|
||||
},
|
||||
set: function(elem, value) {
|
||||
return $(elem).uri().href(value).toString();
|
||||
}
|
||||
};
|
||||
$.each(['src', 'href', 'action', 'uri', 'cite'], function(k, v) {
|
||||
$.attrHooks[v] = {
|
||||
set: _attrHooks.set
|
||||
};
|
||||
});
|
||||
$.attrHooks.uri.get = _attrHooks.get;
|
||||
|
||||
// general URI accessor
|
||||
$.fn.uri = function(uri) {
|
||||
var $this = this.first();
|
||||
var elem = $this.get(0);
|
||||
var property = getUriProperty(elem);
|
||||
|
||||
if (!property) {
|
||||
throw new Error('Element "' + elem.nodeName + '" does not have either property: href, src, action, cite');
|
||||
}
|
||||
|
||||
if (uri !== undefined) {
|
||||
var old = $this.data('uri');
|
||||
if (old) {
|
||||
return old.href(uri);
|
||||
}
|
||||
|
||||
if (!(uri instanceof URI)) {
|
||||
uri = URI(uri || '');
|
||||
}
|
||||
} else {
|
||||
uri = $this.data('uri');
|
||||
if (uri) {
|
||||
return uri;
|
||||
} else {
|
||||
uri = URI($this.attr(property) || '');
|
||||
}
|
||||
}
|
||||
|
||||
uri._dom_element = elem;
|
||||
uri._dom_attribute = property;
|
||||
uri.normalize();
|
||||
$this.data('uri', uri);
|
||||
return uri;
|
||||
};
|
||||
|
||||
// overwrite URI.build() to update associated DOM element if necessary
|
||||
URI.prototype.build = function(deferBuild) {
|
||||
if (this._dom_element) {
|
||||
// cannot defer building when hooked into a DOM element
|
||||
this._string = URI.build(this._parts);
|
||||
this._deferred_build = false;
|
||||
this._dom_element.setAttribute(this._dom_attribute, this._string);
|
||||
this._dom_element[this._dom_attribute] = this._string;
|
||||
} else if (deferBuild === true) {
|
||||
this._deferred_build = true;
|
||||
} else if (deferBuild === undefined || this._deferred_build) {
|
||||
this._string = URI.build(this._parts);
|
||||
this._deferred_build = false;
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
// add :uri() pseudo class selector to sizzle
|
||||
var uriSizzle;
|
||||
var pseudoArgs = /^([a-zA-Z]+)\s*([\^\$*]?=|:)\s*(['"]?)(.+)\3|^\s*([a-zA-Z0-9]+)\s*$/;
|
||||
function uriPseudo (elem, text) {
|
||||
var match, property, uri;
|
||||
|
||||
// skip anything without src|href|action and bad :uri() syntax
|
||||
if (!getUriProperty(elem) || !text) {
|
||||
return false;
|
||||
}
|
||||
|
||||
match = text.match(pseudoArgs);
|
||||
|
||||
if (!match || (!match[5] && match[2] !== ':' && !compare[match[2]])) {
|
||||
// abort because the given selector cannot be executed
|
||||
// filers seem to fail silently
|
||||
return false;
|
||||
}
|
||||
|
||||
uri = $(elem).uri();
|
||||
|
||||
if (match[5]) {
|
||||
return uri.is(match[5]);
|
||||
} else if (match[2] === ':') {
|
||||
property = match[1].toLowerCase() + ':';
|
||||
if (!compare[property]) {
|
||||
// filers seem to fail silently
|
||||
return false;
|
||||
}
|
||||
|
||||
return compare[property](uri, match[4]);
|
||||
} else {
|
||||
property = match[1].toLowerCase();
|
||||
if (!comparable[property]) {
|
||||
// filers seem to fail silently
|
||||
return false;
|
||||
}
|
||||
|
||||
return compare[match[2]](uri[property](), match[4], property);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($.expr.createPseudo) {
|
||||
// jQuery >= 1.8
|
||||
uriSizzle = $.expr.createPseudo(function (text) {
|
||||
return function (elem) {
|
||||
return uriPseudo(elem, text);
|
||||
};
|
||||
});
|
||||
} else {
|
||||
// jQuery < 1.8
|
||||
uriSizzle = function (elem, i, match) {
|
||||
return uriPseudo(elem, match[3]);
|
||||
};
|
||||
}
|
||||
|
||||
$.expr[':'].uri = uriSizzle;
|
||||
|
||||
// extending existing object rather than defining something new,
|
||||
// return jQuery anyway
|
||||
return $;
|
||||
}));
|
||||
7
book/node_modules/urijs/src/jquery.URI.min.js
generated
vendored
Normal file
7
book/node_modules/urijs/src/jquery.URI.min.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/*! URI.js v1.19.11 http://medialize.github.io/URI.js/ */
|
||||
/* build contains: jquery.URI.js */
|
||||
(function(d,e){"object"===typeof module&&module.exports?module.exports=e(require("jquery"),require("./URI")):"function"===typeof define&&define.amd?define(["jquery","./URI"],e):e(d.jQuery,d.URI)})(this,function(d,e){function k(a){return a.replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}function l(a){var b=a.nodeName.toLowerCase();if("input"!==b||"image"===a.type)return e.domAttributes[b]}function p(a){return{get:function(b){return d(b).uri()[a]()},set:function(b,c){d(b).uri()[a](c);return c}}}function m(a,
|
||||
b){if(!l(a)||!b)return!1;var c=b.match(q);if(!c||!c[5]&&":"!==c[2]&&!h[c[2]])return!1;var g=d(a).uri();if(c[5])return g.is(c[5]);if(":"===c[2]){var f=c[1].toLowerCase()+":";return h[f]?h[f](g,c[4]):!1}f=c[1].toLowerCase();return n[f]?h[c[2]](g[f](),c[4],f):!1}var n={},h={"=":function(a,b){return a===b},"^=":function(a,b){return!!(a+"").match(new RegExp("^"+k(b),"i"))},"$=":function(a,b){return!!(a+"").match(new RegExp(k(b)+"$","i"))},"*=":function(a,b,c){"directory"===c&&(a+="/");return!!(a+"").match(new RegExp(k(b),
|
||||
"i"))},"equals:":function(a,b){return a.equals(b)},"is:":function(a,b){return a.is(b)}};d.each("origin authority directory domain filename fragment hash host hostname href password path pathname port protocol query resource scheme search subdomain suffix tld username".split(" "),function(a,b){n[b]=!0;d.attrHooks["uri:"+b]=p(b)});var r=function(a,b){return d(a).uri().href(b).toString()};d.each(["src","href","action","uri","cite"],function(a,b){d.attrHooks[b]={set:r}});d.attrHooks.uri.get=function(a){return d(a).uri()};
|
||||
d.fn.uri=function(a){var b=this.first(),c=b.get(0),g=l(c);if(!g)throw Error('Element "'+c.nodeName+'" does not have either property: href, src, action, cite');if(void 0!==a){var f=b.data("uri");if(f)return f.href(a);a instanceof e||(a=e(a||""))}else{if(a=b.data("uri"))return a;a=e(b.attr(g)||"")}a._dom_element=c;a._dom_attribute=g;a.normalize();b.data("uri",a);return a};e.prototype.build=function(a){if(this._dom_element)this._string=e.build(this._parts),this._deferred_build=!1,this._dom_element.setAttribute(this._dom_attribute,
|
||||
this._string),this._dom_element[this._dom_attribute]=this._string;else if(!0===a)this._deferred_build=!0;else if(void 0===a||this._deferred_build)this._string=e.build(this._parts),this._deferred_build=!1;return this};var q=/^([a-zA-Z]+)\s*([\^\$*]?=|:)\s*(['"]?)(.+)\3|^\s*([a-zA-Z0-9]+)\s*$/;var t=d.expr.createPseudo?d.expr.createPseudo(function(a){return function(b){return m(b,a)}}):function(a,b,c){return m(a,c[3])};d.expr[":"].uri=t;return d});
|
||||
533
book/node_modules/urijs/src/punycode.js
generated
vendored
Normal file
533
book/node_modules/urijs/src/punycode.js
generated
vendored
Normal file
@@ -0,0 +1,533 @@
|
||||
/*! https://mths.be/punycode v1.4.0 by @mathias */
|
||||
;(function(root) {
|
||||
|
||||
/** Detect free variables */
|
||||
var freeExports = typeof exports == 'object' && exports &&
|
||||
!exports.nodeType && exports;
|
||||
var freeModule = typeof module == 'object' && module &&
|
||||
!module.nodeType && module;
|
||||
var freeGlobal = typeof global == 'object' && global;
|
||||
if (
|
||||
freeGlobal.global === freeGlobal ||
|
||||
freeGlobal.window === freeGlobal ||
|
||||
freeGlobal.self === freeGlobal
|
||||
) {
|
||||
root = freeGlobal;
|
||||
}
|
||||
|
||||
/**
|
||||
* The `punycode` object.
|
||||
* @name punycode
|
||||
* @type Object
|
||||
*/
|
||||
var punycode,
|
||||
|
||||
/** Highest positive signed 32-bit float value */
|
||||
maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1
|
||||
|
||||
/** Bootstring parameters */
|
||||
base = 36,
|
||||
tMin = 1,
|
||||
tMax = 26,
|
||||
skew = 38,
|
||||
damp = 700,
|
||||
initialBias = 72,
|
||||
initialN = 128, // 0x80
|
||||
delimiter = '-', // '\x2D'
|
||||
|
||||
/** Regular expressions */
|
||||
regexPunycode = /^xn--/,
|
||||
regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars
|
||||
regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators
|
||||
|
||||
/** Error messages */
|
||||
errors = {
|
||||
'overflow': 'Overflow: input needs wider integers to process',
|
||||
'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
|
||||
'invalid-input': 'Invalid input'
|
||||
},
|
||||
|
||||
/** Convenience shortcuts */
|
||||
baseMinusTMin = base - tMin,
|
||||
floor = Math.floor,
|
||||
stringFromCharCode = String.fromCharCode,
|
||||
|
||||
/** Temporary variable */
|
||||
key;
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* A generic error utility function.
|
||||
* @private
|
||||
* @param {String} type The error type.
|
||||
* @returns {Error} Throws a `RangeError` with the applicable error message.
|
||||
*/
|
||||
function error(type) {
|
||||
throw new RangeError(errors[type]);
|
||||
}
|
||||
|
||||
/**
|
||||
* A generic `Array#map` utility function.
|
||||
* @private
|
||||
* @param {Array} array The array to iterate over.
|
||||
* @param {Function} callback The function that gets called for every array
|
||||
* item.
|
||||
* @returns {Array} A new array of values returned by the callback function.
|
||||
*/
|
||||
function map(array, fn) {
|
||||
var length = array.length;
|
||||
var result = [];
|
||||
while (length--) {
|
||||
result[length] = fn(array[length]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* A simple `Array#map`-like wrapper to work with domain name strings or email
|
||||
* addresses.
|
||||
* @private
|
||||
* @param {String} domain The domain name or email address.
|
||||
* @param {Function} callback The function that gets called for every
|
||||
* character.
|
||||
* @returns {Array} A new string of characters returned by the callback
|
||||
* function.
|
||||
*/
|
||||
function mapDomain(string, fn) {
|
||||
var parts = string.split('@');
|
||||
var result = '';
|
||||
if (parts.length > 1) {
|
||||
// In email addresses, only the domain name should be punycoded. Leave
|
||||
// the local part (i.e. everything up to `@`) intact.
|
||||
result = parts[0] + '@';
|
||||
string = parts[1];
|
||||
}
|
||||
// Avoid `split(regex)` for IE8 compatibility. See #17.
|
||||
string = string.replace(regexSeparators, '\x2E');
|
||||
var labels = string.split('.');
|
||||
var encoded = map(labels, fn).join('.');
|
||||
return result + encoded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an array containing the numeric code points of each Unicode
|
||||
* character in the string. While JavaScript uses UCS-2 internally,
|
||||
* this function will convert a pair of surrogate halves (each of which
|
||||
* UCS-2 exposes as separate characters) into a single code point,
|
||||
* matching UTF-16.
|
||||
* @see `punycode.ucs2.encode`
|
||||
* @see <https://mathiasbynens.be/notes/javascript-encoding>
|
||||
* @memberOf punycode.ucs2
|
||||
* @name decode
|
||||
* @param {String} string The Unicode input string (UCS-2).
|
||||
* @returns {Array} The new array of code points.
|
||||
*/
|
||||
function ucs2decode(string) {
|
||||
var output = [],
|
||||
counter = 0,
|
||||
length = string.length,
|
||||
value,
|
||||
extra;
|
||||
while (counter < length) {
|
||||
value = string.charCodeAt(counter++);
|
||||
if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
|
||||
// high surrogate, and there is a next character
|
||||
extra = string.charCodeAt(counter++);
|
||||
if ((extra & 0xFC00) == 0xDC00) { // low surrogate
|
||||
output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
|
||||
} else {
|
||||
// unmatched surrogate; only append this code unit, in case the next
|
||||
// code unit is the high surrogate of a surrogate pair
|
||||
output.push(value);
|
||||
counter--;
|
||||
}
|
||||
} else {
|
||||
output.push(value);
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a string based on an array of numeric code points.
|
||||
* @see `punycode.ucs2.decode`
|
||||
* @memberOf punycode.ucs2
|
||||
* @name encode
|
||||
* @param {Array} codePoints The array of numeric code points.
|
||||
* @returns {String} The new Unicode string (UCS-2).
|
||||
*/
|
||||
function ucs2encode(array) {
|
||||
return map(array, function(value) {
|
||||
var output = '';
|
||||
if (value > 0xFFFF) {
|
||||
value -= 0x10000;
|
||||
output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
|
||||
value = 0xDC00 | value & 0x3FF;
|
||||
}
|
||||
output += stringFromCharCode(value);
|
||||
return output;
|
||||
}).join('');
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a basic code point into a digit/integer.
|
||||
* @see `digitToBasic()`
|
||||
* @private
|
||||
* @param {Number} codePoint The basic numeric code point value.
|
||||
* @returns {Number} The numeric value of a basic code point (for use in
|
||||
* representing integers) in the range `0` to `base - 1`, or `base` if
|
||||
* the code point does not represent a value.
|
||||
*/
|
||||
function basicToDigit(codePoint) {
|
||||
if (codePoint - 48 < 10) {
|
||||
return codePoint - 22;
|
||||
}
|
||||
if (codePoint - 65 < 26) {
|
||||
return codePoint - 65;
|
||||
}
|
||||
if (codePoint - 97 < 26) {
|
||||
return codePoint - 97;
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a digit/integer into a basic code point.
|
||||
* @see `basicToDigit()`
|
||||
* @private
|
||||
* @param {Number} digit The numeric value of a basic code point.
|
||||
* @returns {Number} The basic code point whose value (when used for
|
||||
* representing integers) is `digit`, which needs to be in the range
|
||||
* `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
|
||||
* used; else, the lowercase form is used. The behavior is undefined
|
||||
* if `flag` is non-zero and `digit` has no uppercase form.
|
||||
*/
|
||||
function digitToBasic(digit, flag) {
|
||||
// 0..25 map to ASCII a..z or A..Z
|
||||
// 26..35 map to ASCII 0..9
|
||||
return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bias adaptation function as per section 3.4 of RFC 3492.
|
||||
* https://tools.ietf.org/html/rfc3492#section-3.4
|
||||
* @private
|
||||
*/
|
||||
function adapt(delta, numPoints, firstTime) {
|
||||
var k = 0;
|
||||
delta = firstTime ? floor(delta / damp) : delta >> 1;
|
||||
delta += floor(delta / numPoints);
|
||||
for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {
|
||||
delta = floor(delta / baseMinusTMin);
|
||||
}
|
||||
return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a Punycode string of ASCII-only symbols to a string of Unicode
|
||||
* symbols.
|
||||
* @memberOf punycode
|
||||
* @param {String} input The Punycode string of ASCII-only symbols.
|
||||
* @returns {String} The resulting string of Unicode symbols.
|
||||
*/
|
||||
function decode(input) {
|
||||
// Don't use UCS-2
|
||||
var output = [],
|
||||
inputLength = input.length,
|
||||
out,
|
||||
i = 0,
|
||||
n = initialN,
|
||||
bias = initialBias,
|
||||
basic,
|
||||
j,
|
||||
index,
|
||||
oldi,
|
||||
w,
|
||||
k,
|
||||
digit,
|
||||
t,
|
||||
/** Cached calculation results */
|
||||
baseMinusT;
|
||||
|
||||
// Handle the basic code points: let `basic` be the number of input code
|
||||
// points before the last delimiter, or `0` if there is none, then copy
|
||||
// the first basic code points to the output.
|
||||
|
||||
basic = input.lastIndexOf(delimiter);
|
||||
if (basic < 0) {
|
||||
basic = 0;
|
||||
}
|
||||
|
||||
for (j = 0; j < basic; ++j) {
|
||||
// if it's not a basic code point
|
||||
if (input.charCodeAt(j) >= 0x80) {
|
||||
error('not-basic');
|
||||
}
|
||||
output.push(input.charCodeAt(j));
|
||||
}
|
||||
|
||||
// Main decoding loop: start just after the last delimiter if any basic code
|
||||
// points were copied; start at the beginning otherwise.
|
||||
|
||||
for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {
|
||||
|
||||
// `index` is the index of the next character to be consumed.
|
||||
// Decode a generalized variable-length integer into `delta`,
|
||||
// which gets added to `i`. The overflow checking is easier
|
||||
// if we increase `i` as we go, then subtract off its starting
|
||||
// value at the end to obtain `delta`.
|
||||
for (oldi = i, w = 1, k = base; /* no condition */; k += base) {
|
||||
|
||||
if (index >= inputLength) {
|
||||
error('invalid-input');
|
||||
}
|
||||
|
||||
digit = basicToDigit(input.charCodeAt(index++));
|
||||
|
||||
if (digit >= base || digit > floor((maxInt - i) / w)) {
|
||||
error('overflow');
|
||||
}
|
||||
|
||||
i += digit * w;
|
||||
t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
|
||||
|
||||
if (digit < t) {
|
||||
break;
|
||||
}
|
||||
|
||||
baseMinusT = base - t;
|
||||
if (w > floor(maxInt / baseMinusT)) {
|
||||
error('overflow');
|
||||
}
|
||||
|
||||
w *= baseMinusT;
|
||||
|
||||
}
|
||||
|
||||
out = output.length + 1;
|
||||
bias = adapt(i - oldi, out, oldi == 0);
|
||||
|
||||
// `i` was supposed to wrap around from `out` to `0`,
|
||||
// incrementing `n` each time, so we'll fix that now:
|
||||
if (floor(i / out) > maxInt - n) {
|
||||
error('overflow');
|
||||
}
|
||||
|
||||
n += floor(i / out);
|
||||
i %= out;
|
||||
|
||||
// Insert `n` at position `i` of the output
|
||||
output.splice(i++, 0, n);
|
||||
|
||||
}
|
||||
|
||||
return ucs2encode(output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a string of Unicode symbols (e.g. a domain name label) to a
|
||||
* Punycode string of ASCII-only symbols.
|
||||
* @memberOf punycode
|
||||
* @param {String} input The string of Unicode symbols.
|
||||
* @returns {String} The resulting Punycode string of ASCII-only symbols.
|
||||
*/
|
||||
function encode(input) {
|
||||
var n,
|
||||
delta,
|
||||
handledCPCount,
|
||||
basicLength,
|
||||
bias,
|
||||
j,
|
||||
m,
|
||||
q,
|
||||
k,
|
||||
t,
|
||||
currentValue,
|
||||
output = [],
|
||||
/** `inputLength` will hold the number of code points in `input`. */
|
||||
inputLength,
|
||||
/** Cached calculation results */
|
||||
handledCPCountPlusOne,
|
||||
baseMinusT,
|
||||
qMinusT;
|
||||
|
||||
// Convert the input in UCS-2 to Unicode
|
||||
input = ucs2decode(input);
|
||||
|
||||
// Cache the length
|
||||
inputLength = input.length;
|
||||
|
||||
// Initialize the state
|
||||
n = initialN;
|
||||
delta = 0;
|
||||
bias = initialBias;
|
||||
|
||||
// Handle the basic code points
|
||||
for (j = 0; j < inputLength; ++j) {
|
||||
currentValue = input[j];
|
||||
if (currentValue < 0x80) {
|
||||
output.push(stringFromCharCode(currentValue));
|
||||
}
|
||||
}
|
||||
|
||||
handledCPCount = basicLength = output.length;
|
||||
|
||||
// `handledCPCount` is the number of code points that have been handled;
|
||||
// `basicLength` is the number of basic code points.
|
||||
|
||||
// Finish the basic string - if it is not empty - with a delimiter
|
||||
if (basicLength) {
|
||||
output.push(delimiter);
|
||||
}
|
||||
|
||||
// Main encoding loop:
|
||||
while (handledCPCount < inputLength) {
|
||||
|
||||
// All non-basic code points < n have been handled already. Find the next
|
||||
// larger one:
|
||||
for (m = maxInt, j = 0; j < inputLength; ++j) {
|
||||
currentValue = input[j];
|
||||
if (currentValue >= n && currentValue < m) {
|
||||
m = currentValue;
|
||||
}
|
||||
}
|
||||
|
||||
// Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
|
||||
// but guard against overflow
|
||||
handledCPCountPlusOne = handledCPCount + 1;
|
||||
if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
|
||||
error('overflow');
|
||||
}
|
||||
|
||||
delta += (m - n) * handledCPCountPlusOne;
|
||||
n = m;
|
||||
|
||||
for (j = 0; j < inputLength; ++j) {
|
||||
currentValue = input[j];
|
||||
|
||||
if (currentValue < n && ++delta > maxInt) {
|
||||
error('overflow');
|
||||
}
|
||||
|
||||
if (currentValue == n) {
|
||||
// Represent delta as a generalized variable-length integer
|
||||
for (q = delta, k = base; /* no condition */; k += base) {
|
||||
t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
|
||||
if (q < t) {
|
||||
break;
|
||||
}
|
||||
qMinusT = q - t;
|
||||
baseMinusT = base - t;
|
||||
output.push(
|
||||
stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
|
||||
);
|
||||
q = floor(qMinusT / baseMinusT);
|
||||
}
|
||||
|
||||
output.push(stringFromCharCode(digitToBasic(q, 0)));
|
||||
bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
|
||||
delta = 0;
|
||||
++handledCPCount;
|
||||
}
|
||||
}
|
||||
|
||||
++delta;
|
||||
++n;
|
||||
|
||||
}
|
||||
return output.join('');
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a Punycode string representing a domain name or an email address
|
||||
* to Unicode. Only the Punycoded parts of the input will be converted, i.e.
|
||||
* it doesn't matter if you call it on a string that has already been
|
||||
* converted to Unicode.
|
||||
* @memberOf punycode
|
||||
* @param {String} input The Punycoded domain name or email address to
|
||||
* convert to Unicode.
|
||||
* @returns {String} The Unicode representation of the given Punycode
|
||||
* string.
|
||||
*/
|
||||
function toUnicode(input) {
|
||||
return mapDomain(input, function(string) {
|
||||
return regexPunycode.test(string)
|
||||
? decode(string.slice(4).toLowerCase())
|
||||
: string;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a Unicode string representing a domain name or an email address to
|
||||
* Punycode. Only the non-ASCII parts of the domain name will be converted,
|
||||
* i.e. it doesn't matter if you call it with a domain that's already in
|
||||
* ASCII.
|
||||
* @memberOf punycode
|
||||
* @param {String} input The domain name or email address to convert, as a
|
||||
* Unicode string.
|
||||
* @returns {String} The Punycode representation of the given domain name or
|
||||
* email address.
|
||||
*/
|
||||
function toASCII(input) {
|
||||
return mapDomain(input, function(string) {
|
||||
return regexNonASCII.test(string)
|
||||
? 'xn--' + encode(string)
|
||||
: string;
|
||||
});
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/** Define the public API */
|
||||
punycode = {
|
||||
/**
|
||||
* A string representing the current Punycode.js version number.
|
||||
* @memberOf punycode
|
||||
* @type String
|
||||
*/
|
||||
'version': '1.3.2',
|
||||
/**
|
||||
* An object of methods to convert from JavaScript's internal character
|
||||
* representation (UCS-2) to Unicode code points, and back.
|
||||
* @see <https://mathiasbynens.be/notes/javascript-encoding>
|
||||
* @memberOf punycode
|
||||
* @type Object
|
||||
*/
|
||||
'ucs2': {
|
||||
'decode': ucs2decode,
|
||||
'encode': ucs2encode
|
||||
},
|
||||
'decode': decode,
|
||||
'encode': encode,
|
||||
'toASCII': toASCII,
|
||||
'toUnicode': toUnicode
|
||||
};
|
||||
|
||||
/** Expose `punycode` */
|
||||
// Some AMD build optimizers, like r.js, check for specific condition patterns
|
||||
// like the following:
|
||||
if (
|
||||
typeof define == 'function' &&
|
||||
typeof define.amd == 'object' &&
|
||||
define.amd
|
||||
) {
|
||||
define('punycode', function() {
|
||||
return punycode;
|
||||
});
|
||||
} else if (freeExports && freeModule) {
|
||||
if (module.exports == freeExports) {
|
||||
// in Node.js, io.js, or RingoJS v0.8.0+
|
||||
freeModule.exports = punycode;
|
||||
} else {
|
||||
// in Narwhal or RingoJS v0.7.0-
|
||||
for (key in punycode) {
|
||||
punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// in Rhino or a web browser
|
||||
root.punycode = punycode;
|
||||
}
|
||||
|
||||
}(this));
|
||||
Reference in New Issue
Block a user