Socket
Socket
Sign inDemoInstall

uri-js

Package Overview
Dependencies
1
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.2 to 4.2.0

yarn.lock

7

dist/es5/uri.all.d.ts

@@ -21,6 +21,6 @@ export interface URIComponents {

}
export interface URISchemeHandler {
export interface URISchemeHandler<Components extends URIComponents = URIComponents, Options extends URIOptions = URIOptions, ParentComponents extends URIComponents = URIComponents> {
scheme: string;
parse(components: URIComponents, options: URIOptions): URIComponents;
serialize(components: URIComponents, options: URIOptions): URIComponents;
parse(components: ParentComponents, options: Options): Components;
serialize(components: Components, options: Options): ParentComponents;
unicodeSupport?: boolean;

@@ -42,2 +42,3 @@ domainHost?: boolean;

PCT_ENCODED: RegExp;
IPV4ADDRESS: RegExp;
IPV6ADDRESS: RegExp;

@@ -44,0 +45,0 @@ }

@@ -1,2 +0,2 @@

/** @license URI.js v3.0.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */
/** @license URI.js v4.1.0 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */
(function (global, factory) {

@@ -60,3 +60,5 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :

DEC_OCTET$ = subexp(subexp("25[0-5]") + "|" + subexp("2[0-4]" + DIGIT$$) + "|" + subexp("1" + DIGIT$$ + DIGIT$$) + "|" + subexp("[1-9]" + DIGIT$$) + "|" + DIGIT$$),
IPV4ADDRESS$ = subexp(DEC_OCTET$ + "\\." + DEC_OCTET$ + "\\." + DEC_OCTET$ + "\\." + DEC_OCTET$),
DEC_OCTET_RELAXED$ = subexp(subexp("25[0-5]") + "|" + subexp("2[0-4]" + DIGIT$$) + "|" + subexp("1" + DIGIT$$ + DIGIT$$) + "|" + subexp("0?[1-9]" + DIGIT$$) + "|0?0?" + DIGIT$$),
//relaxed parsing rules
IPV4ADDRESS$ = subexp(DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$),
H16$ = subexp(HEXDIG$$ + "{1,4}"),

@@ -83,5 +85,12 @@ LS32$ = subexp(subexp(H16$ + "\\:" + H16$) + "|" + IPV4ADDRESS$),

IPV6ADDRESS$ = subexp([IPV6ADDRESS1$, IPV6ADDRESS2$, IPV6ADDRESS3$, IPV6ADDRESS4$, IPV6ADDRESS5$, IPV6ADDRESS6$, IPV6ADDRESS7$, IPV6ADDRESS8$, IPV6ADDRESS9$].join("|")),
IPVFUTURE$ = subexp("[vV]" + HEXDIG$$ + "+\\." + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:]") + "+"),
IP_LITERAL$ = subexp("\\[" + subexp(IPV6ADDRESS$ + "|" + IPVFUTURE$) + "\\]"),
REG_NAME$ = subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$)) + "*"),
ZONEID$ = subexp(subexp(UNRESERVED$$ + "|" + PCT_ENCODED$) + "+"),
//RFC 6874
IPV6ADDRZ$ = subexp(IPV6ADDRESS$ + "\\%25" + ZONEID$),
//RFC 6874
IPV6ADDRZ_RELAXED$ = subexp(IPV6ADDRESS$ + subexp("\\%25|\\%(?!" + HEXDIG$$ + "{2})") + ZONEID$),
//RFC 6874, with relaxed parsing rules
IPVFUTURE$ = subexp("[vV]" + HEXDIG$$ + "+\\." + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:]") + "+"),
IP_LITERAL$ = subexp("\\[" + subexp(IPV6ADDRZ_RELAXED$ + "|" + IPV6ADDRESS$ + "|" + IPVFUTURE$) + "\\]"),
//RFC 6874
REG_NAME$ = subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$)) + "*"),
HOST$ = subexp(IP_LITERAL$ + "|" + IPV4ADDRESS$ + "(?!" + REG_NAME$ + ")" + "|" + REG_NAME$),

@@ -128,3 +137,4 @@ PORT$ = subexp(DIGIT$$ + "*"),

PCT_ENCODED: new RegExp(PCT_ENCODED$, "g"),
IPV6ADDRESS: new RegExp("\\[?(" + IPV6ADDRESS$ + ")\\]?", "g")
IPV4ADDRESS: new RegExp("^(" + IPV4ADDRESS$ + ")$"),
IPV6ADDRESS: new RegExp("^\\[?(" + IPV6ADDRESS$ + ")" + subexp(subexp("\\%25|\\%(?!" + HEXDIG$$ + "{2})") + "(" + ZONEID$ + ")") + "?\\]?$") //RFC 6874, with relaxed parsing rules
};

@@ -136,2 +146,52 @@ }

var slicedToArray = function () {
function sliceIterator(arr, i) {
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"]) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
return function (arr, i) {
if (Array.isArray(arr)) {
return arr;
} else if (Symbol.iterator in Object(arr)) {
return sliceIterator(arr, i);
} else {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
};
}();
var toConsumableArray = function (arr) {

@@ -731,3 +791,73 @@ if (Array.isArray(arr)) {

var URI_PARSE = /^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[\dA-F:.]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i;
function _stripLeadingZeros(str) {
return str.replace(/^0*(.*)/, "$1") || "0";
}
function _normalizeIPv4(host, protocol) {
var matches = host.match(protocol.IPV4ADDRESS) || [];
var _matches = slicedToArray(matches, 2),
address = _matches[1];
if (address) {
return address.split(".").map(_stripLeadingZeros).join(".");
} else {
return host;
}
}
function _normalizeIPv6(host, protocol) {
var matches = host.match(protocol.IPV6ADDRESS) || [];
var _matches2 = slicedToArray(matches, 3),
address = _matches2[1],
zone = _matches2[2];
if (address) {
var _address$toLowerCase$ = address.toLowerCase().split('::').reverse(),
_address$toLowerCase$2 = slicedToArray(_address$toLowerCase$, 2),
last = _address$toLowerCase$2[0],
first = _address$toLowerCase$2[1];
var firstFields = first ? first.split(":").map(_stripLeadingZeros) : [];
var lastFields = last.split(":").map(_stripLeadingZeros);
var isLastFieldIPv4Address = protocol.IPV4ADDRESS.test(lastFields[lastFields.length - 1]);
var fieldCount = isLastFieldIPv4Address ? 7 : 8;
var lastFieldsStart = lastFields.length - fieldCount;
var fields = Array(fieldCount);
for (var x = 0; x < fieldCount; ++x) {
fields[x] = firstFields[x] || lastFields[lastFieldsStart + x] || '';
}
if (isLastFieldIPv4Address) {
fields[fieldCount - 1] = _normalizeIPv4(fields[fieldCount - 1], protocol);
}
var allZeroFields = fields.reduce(function (acc, field, index) {
if (!field || field === "0") {
var lastLongest = acc[acc.length - 1];
if (lastLongest && lastLongest.index + lastLongest.length === index) {
lastLongest.length++;
} else {
acc.push({ index: index, length: 1 });
}
}
return acc;
}, []);
var longestZeroFields = allZeroFields.sort(function (a, b) {
return b.length - a.length;
})[0];
var newHost = void 0;
if (longestZeroFields && longestZeroFields.length > 1) {
var newFirst = fields.slice(0, longestZeroFields.index);
var newLast = fields.slice(longestZeroFields.index + longestZeroFields.length);
newHost = newFirst.join(":") + "::" + newLast.join(":");
} else {
newHost = fields.join(":");
}
if (zone) {
newHost += "%" + zone;
}
return newHost;
} else {
return host;
}
}
var URI_PARSE = /^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i;
var NO_MATCH_IS_UNDEFINED = "".match(/(){0}/)[1] === undefined;

@@ -756,2 +886,3 @@ function parse(uriString) {

} else {
//IE FIX for improper RegExp matching
//store each component

@@ -770,5 +901,5 @@ components.scheme = matches[1] || undefined;

}
//strip brackets from IPv6 hosts
if (components.host) {
components.host = components.host.replace(protocol.IPV6ADDRESS, "$1");
//normalize IP hosts
components.host = _normalizeIPv6(_normalizeIPv4(components.host, protocol), protocol);
}

@@ -826,4 +957,6 @@ //determine reference type

if (components.host !== undefined) {
//ensure IPv6 addresses are bracketed
uriTokens.push(String(components.host).replace(protocol.IPV6ADDRESS, "[$1]"));
//normalize IP hosts, add brackets and escape zone separator for IPv6
uriTokens.push(_normalizeIPv6(_normalizeIPv4(String(components.host), protocol), protocol).replace(protocol.IPV6ADDRESS, function (_, $1, $2) {
return "[" + $1 + ($2 ? "%25" + $2 : "") + "]";
}));
}

@@ -878,12 +1011,14 @@ if (typeof components.port === "number") {

//if host component is an IPv6 address
if (protocol.IPV6ADDRESS.test(components.host)) {
//TODO: normalize IPv6 address as per RFC 5952
} else if (options.domainHost || schemeHandler && schemeHandler.domainHost) {
//convert IDN via punycode
try {
components.host = !options.iri ? punycode.toASCII(components.host.replace(protocol.PCT_ENCODED, pctDecChars).toLowerCase()) : punycode.toUnicode(components.host);
} catch (e) {
components.error = components.error || "Host's domain name can not be converted to " + (!options.iri ? "ASCII" : "Unicode") + " via punycode: " + e;
if (protocol.IPV6ADDRESS.test(components.host)) {}
//TODO: normalize IPv6 address as per RFC 5952
//if host component is a domain name
else if (options.domainHost || schemeHandler && schemeHandler.domainHost) {
//convert IDN via punycode
try {
components.host = !options.iri ? punycode.toASCII(components.host.replace(protocol.PCT_ENCODED, pctDecChars).toLowerCase()) : punycode.toUnicode(components.host);
} catch (e) {
components.error = components.error || "Host's domain name can not be converted to " + (!options.iri ? "ASCII" : "Unicode") + " via punycode: " + e;
}
}
}
}

@@ -1022,3 +1157,3 @@ //normalize encoding

var http = {
var handler = {
scheme: "http",

@@ -1049,7 +1184,7 @@ domainHost: true,

var https = {
var handler$1 = {
scheme: "https",
domainHost: http.domainHost,
parse: http.parse,
serialize: http.serialize
domainHost: handler.domainHost,
parse: handler.parse,
serialize: handler.serialize
};

@@ -1087,11 +1222,12 @@

}
var mailto = {
var handler$2 = {
scheme: "mailto",
parse: function parse$$1(components, options) {
var to = components.to = components.path ? components.path.split(",") : [];
components.path = undefined;
if (components.query) {
var mailtoComponents = components;
var to = mailtoComponents.to = mailtoComponents.path ? mailtoComponents.path.split(",") : [];
mailtoComponents.path = undefined;
if (mailtoComponents.query) {
var unknownHeaders = false;
var headers = {};
var hfields = components.query.split("&");
var hfields = mailtoComponents.query.split("&");
for (var x = 0, xl = hfields.length; x < xl; ++x) {

@@ -1107,6 +1243,6 @@ var hfield = hfields[x].split("=");

case "subject":
components.subject = unescapeComponent(hfield[1], options);
mailtoComponents.subject = unescapeComponent(hfield[1], options);
break;
case "body":
components.body = unescapeComponent(hfield[1], options);
mailtoComponents.body = unescapeComponent(hfield[1], options);
break;

@@ -1119,5 +1255,5 @@ default:

}
if (unknownHeaders) components.headers = headers;
if (unknownHeaders) mailtoComponents.headers = headers;
}
components.query = undefined;
mailtoComponents.query = undefined;
for (var _x2 = 0, _xl2 = to.length; _x2 < _xl2; ++_x2) {

@@ -1131,3 +1267,3 @@ var addr = to[_x2].split("@");

} catch (e) {
components.error = components.error || "Email address's domain name can not be converted to ASCII via punycode: " + e;
mailtoComponents.error = mailtoComponents.error || "Email address's domain name can not be converted to ASCII via punycode: " + e;
}

@@ -1139,6 +1275,7 @@ } else {

}
return components;
return mailtoComponents;
},
serialize: function serialize$$1(components, options) {
var to = toArray(components.to);
serialize: function serialize$$1(mailtoComponents, options) {
var components = mailtoComponents;
var to = toArray(mailtoComponents.to);
if (to) {

@@ -1160,5 +1297,5 @@ for (var x = 0, xl = to.length; x < xl; ++x) {

}
var headers = components.headers = components.headers || {};
if (components.subject) headers["subject"] = components.subject;
if (components.body) headers["body"] = components.body;
var headers = mailtoComponents.headers = mailtoComponents.headers || {};
if (mailtoComponents.subject) headers["subject"] = mailtoComponents.subject;
if (mailtoComponents.body) headers["body"] = mailtoComponents.body;
var fields = [];

@@ -1177,42 +1314,38 @@ for (var name in headers) {

var NID$ = "(?:[0-9A-Za-z][0-9A-Za-z\\-]{1,31})";
var URN_SCHEME = new RegExp("^urn\\:(" + NID$ + ")$");
var URN_PARSE = /^([^\:]+)\:(.*)/;
var URN_EXCLUDED = /[\x00-\x20\\\"\&\<\>\[\]\^\`\{\|\}\~\x7F-\xFF]/g;
//RFC 2141
var urn = {
var handler$3 = {
scheme: "urn",
parse: function parse$$1(components, options) {
var matches = components.path && components.path.match(URN_PARSE);
var urnComponents = components;
if (matches) {
var scheme = "urn:" + matches[1].toLowerCase();
var schemeHandler = SCHEMES[scheme];
//in order to serialize properly,
//every URN must have a serializer that calls the URN serializer
if (!schemeHandler) {
//create fake scheme handler
schemeHandler = SCHEMES[scheme] = {
scheme: scheme,
parse: function parse$$1(components, options) {
return components;
},
serialize: SCHEMES["urn"].serialize
};
var scheme = options.scheme || urnComponents.scheme || "urn";
var nid = matches[1].toLowerCase();
var nss = matches[2];
var urnScheme = scheme + ":" + (options.nid || nid);
var schemeHandler = SCHEMES[urnScheme];
urnComponents.nid = nid;
urnComponents.nss = nss;
urnComponents.path = undefined;
if (schemeHandler) {
urnComponents = schemeHandler.parse(urnComponents, options);
}
components.scheme = scheme;
components.path = matches[2];
components = schemeHandler.parse(components, options);
} else {
components.error = components.error || "URN can not be parsed.";
urnComponents.error = urnComponents.error || "URN can not be parsed.";
}
return components;
return urnComponents;
},
serialize: function serialize$$1(components, options) {
var scheme = components.scheme || options.scheme;
if (scheme && scheme !== "urn") {
var matches = scheme.match(URN_SCHEME) || ["urn:" + scheme, scheme];
components.scheme = "urn";
components.path = matches[1] + ":" + (components.path ? components.path.replace(URN_EXCLUDED, pctEncChar) : "");
serialize: function serialize$$1(urnComponents, options) {
var scheme = options.scheme || urnComponents.scheme || "urn";
var nid = urnComponents.nid;
var urnScheme = scheme + ":" + (options.nid || nid);
var schemeHandler = SCHEMES[urnScheme];
if (schemeHandler) {
urnComponents = schemeHandler.serialize(urnComponents, options);
}
return components;
var uriComponents = urnComponents;
var nss = urnComponents.nss;
uriComponents.path = (nid || options.nid) + ":" + nss;
return uriComponents;
}

@@ -1223,28 +1356,26 @@ };

//RFC 4122
var uuid = {
var handler$4 = {
scheme: "urn:uuid",
parse: function parse$$1(components, options) {
if (!options.tolerant && (!components.path || !components.path.match(UUID))) {
components.error = components.error || "UUID is not valid.";
parse: function parse(urnComponents, options) {
var uuidComponents = urnComponents;
uuidComponents.uuid = uuidComponents.nss;
uuidComponents.nss = undefined;
if (!options.tolerant && (!uuidComponents.uuid || !uuidComponents.uuid.match(UUID))) {
uuidComponents.error = uuidComponents.error || "UUID is not valid.";
}
return components;
return uuidComponents;
},
serialize: function serialize$$1(components, options) {
//ensure UUID is valid
if (!options.tolerant && (!components.path || !components.path.match(UUID))) {
//invalid UUIDs can not have this scheme
components.scheme = undefined;
} else {
//normalize UUID
components.path = (components.path || "").toLowerCase();
}
return SCHEMES["urn"].serialize(components, options);
serialize: function serialize(uuidComponents, options) {
var urnComponents = uuidComponents;
//normalize UUID
urnComponents.nss = (uuidComponents.uuid || "").toLowerCase();
return urnComponents;
}
};
SCHEMES["http"] = http;
SCHEMES["https"] = https;
SCHEMES["mailto"] = mailto;
SCHEMES["urn"] = urn;
SCHEMES["urn:uuid"] = uuid;
SCHEMES[handler.scheme] = handler;
SCHEMES[handler$1.scheme] = handler$1;
SCHEMES[handler$2.scheme] = handler$2;
SCHEMES[handler$3.scheme] = handler$3;
SCHEMES[handler$4.scheme] = handler$4;

@@ -1251,0 +1382,0 @@ exports.SCHEMES = SCHEMES;

@@ -21,6 +21,6 @@ export interface URIComponents {

}
export interface URISchemeHandler {
export interface URISchemeHandler<Components extends URIComponents = URIComponents, Options extends URIOptions = URIOptions, ParentComponents extends URIComponents = URIComponents> {
scheme: string;
parse(components: URIComponents, options: URIOptions): URIComponents;
serialize(components: URIComponents, options: URIOptions): URIComponents;
parse(components: ParentComponents, options: Options): Components;
serialize(components: Components, options: Options): ParentComponents;
unicodeSupport?: boolean;

@@ -42,2 +42,3 @@ domainHost?: boolean;

PCT_ENCODED: RegExp;
IPV4ADDRESS: RegExp;
IPV6ADDRESS: RegExp;

@@ -44,0 +45,0 @@ }

@@ -1,3 +0,3 @@

/** @license URI.js v3.0.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(e.URI=e.URI||{})}(this,function(e){"use strict";function r(){for(var e=arguments.length,r=Array(e),t=0;t<e;t++)r[t]=arguments[t];if(r.length>1){r[0]=r[0].slice(0,-1);for(var n=r.length-1,o=1;o<n;++o)r[o]=r[o].slice(1,-1);return r[n]=r[n].slice(1),r.join("")}return r[0]}function t(e){return"(?:"+e+")"}function n(e){return e===undefined?"undefined":null===e?"null":Object.prototype.toString.call(e).split(" ").pop().split("]").shift().toLowerCase()}function o(e){return e.toUpperCase()}function a(e){return e!==undefined&&null!==e?e instanceof Array?e:"number"!=typeof e.length||e.split||e.setInterval||e.call?[e]:Array.prototype.slice.call(e):[]}function i(e){var n=r("[0-9]","[A-Fa-f]"),o=t(t("%[EFef]"+n+"%"+n+n+"%"+n+n)+"|"+t("%[89A-Fa-f]"+n+"%"+n+n)+"|"+t("%"+n+n)),a="[\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=]",i=r("[\\:\\/\\?\\#\\[\\]\\@]",a),u=e?"[\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]":"[]",s=e?"[\\uE000-\\uF8FF]":"[]",p=r("[A-Za-z]","[0-9]","[\\-\\.\\_\\~]",u),f=t(t("25[0-5]")+"|"+t("2[0-4][0-9]")+"|"+t("1[0-9][0-9]")+"|"+t("[1-9][0-9]")+"|[0-9]"),c=t(f+"\\."+f+"\\."+f+"\\."+f),h=t(n+"{1,4}"),d=t(t(h+"\\:"+h)+"|"+c),l=t(t(h+"\\:")+"{6}"+d),g=t("\\:\\:"+t(h+"\\:")+"{5}"+d),m=t(t(h)+"?\\:\\:"+t(h+"\\:")+"{4}"+d),v=t(t(t(h+"\\:")+"{0,1}"+h)+"?\\:\\:"+t(h+"\\:")+"{3}"+d),E=t(t(t(h+"\\:")+"{0,2}"+h)+"?\\:\\:"+t(h+"\\:")+"{2}"+d),C=t(t(t(h+"\\:")+"{0,3}"+h)+"?\\:\\:"+h+"\\:"+d),y=t(t(t(h+"\\:")+"{0,4}"+h)+"?\\:\\:"+d),S=t(t(t(h+"\\:")+"{0,5}"+h)+"?\\:\\:"+h),A=t(t(t(h+"\\:")+"{0,6}"+h)+"?\\:\\:"),D=t([l,g,m,v,E,C,y,S,A].join("|"));return{NOT_SCHEME:new RegExp(r("[^]","[A-Za-z]","[0-9]","[\\+\\-\\.]"),"g"),NOT_USERINFO:new RegExp(r("[^\\%\\:]",p,a),"g"),NOT_HOST:new RegExp(r("[^\\%\\[\\]\\:]",p,a),"g"),NOT_PATH:new RegExp(r("[^\\%\\/\\:\\@]",p,a),"g"),NOT_PATH_NOSCHEME:new RegExp(r("[^\\%\\/\\@]",p,a),"g"),NOT_QUERY:new RegExp(r("[^\\%]",p,a,"[\\:\\@\\/\\?]",s),"g"),NOT_FRAGMENT:new RegExp(r("[^\\%]",p,a,"[\\:\\@\\/\\?]"),"g"),ESCAPE:new RegExp(r("[^]",p,a),"g"),UNRESERVED:new RegExp(p,"g"),OTHER_CHARS:new RegExp(r("[^\\%]",p,i),"g"),PCT_ENCODED:new RegExp(o,"g"),IPV6ADDRESS:new RegExp("\\[?("+D+")\\]?","g")}}function u(e){throw new RangeError(R[e])}function s(e,r){for(var t=[],n=e.length;n--;)t[n]=r(e[n]);return t}function p(e,r){var t=e.split("@"),n="";return t.length>1&&(n=t[0]+"@",e=t[1]),e=e.replace(T,"."),n+s(e.split("."),r).join(".")}function f(e){for(var r=[],t=0,n=e.length;t<n;){var o=e.charCodeAt(t++);if(o>=55296&&o<=56319&&t<n){var a=e.charCodeAt(t++);56320==(64512&a)?r.push(((1023&o)<<10)+(1023&a)+65536):(r.push(o),t--)}else r.push(o)}return r}function c(e){var r=e.charCodeAt(0);return r<16?"%0"+r.toString(16).toUpperCase():r<128?"%"+r.toString(16).toUpperCase():r<2048?"%"+(r>>6|192).toString(16).toUpperCase()+"%"+(63&r|128).toString(16).toUpperCase():"%"+(r>>12|224).toString(16).toUpperCase()+"%"+(r>>6&63|128).toString(16).toUpperCase()+"%"+(63&r|128).toString(16).toUpperCase()}function h(e){for(var r="",t=0,n=e.length;t<n;){var o=parseInt(e.substr(t+1,2),16);if(o<128)r+=String.fromCharCode(o),t+=3;else if(o>=194&&o<224){if(n-t>=6){var a=parseInt(e.substr(t+4,2),16);r+=String.fromCharCode((31&o)<<6|63&a)}else r+=e.substr(t,6);t+=6}else if(o>=224){if(n-t>=9){var i=parseInt(e.substr(t+4,2),16),u=parseInt(e.substr(t+7,2),16);r+=String.fromCharCode((15&o)<<12|(63&i)<<6|63&u)}else r+=e.substr(t,9);t+=9}else r+=e.substr(t,3),t+=3}return r}function d(e,r){function t(e){var t=h(e);return t.match(r.UNRESERVED)?t:e}return e.scheme&&(e.scheme=String(e.scheme).replace(r.PCT_ENCODED,t).toLowerCase().replace(r.NOT_SCHEME,"")),e.userinfo!==undefined&&(e.userinfo=String(e.userinfo).replace(r.PCT_ENCODED,t).replace(r.NOT_USERINFO,c).replace(r.PCT_ENCODED,o)),e.host!==undefined&&(e.host=String(e.host).replace(r.PCT_ENCODED,t).toLowerCase().replace(r.NOT_HOST,c).replace(r.PCT_ENCODED,o)),e.path!==undefined&&(e.path=String(e.path).replace(r.PCT_ENCODED,t).replace(e.scheme?r.NOT_PATH:r.NOT_PATH_NOSCHEME,c).replace(r.PCT_ENCODED,o)),e.query!==undefined&&(e.query=String(e.query).replace(r.PCT_ENCODED,t).replace(r.NOT_QUERY,c).replace(r.PCT_ENCODED,o)),e.fragment!==undefined&&(e.fragment=String(e.fragment).replace(r.PCT_ENCODED,t).replace(r.NOT_FRAGMENT,c).replace(r.PCT_ENCODED,o)),e}function l(e){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},t={},n=r.iri!==!1?w:x;"suffix"===r.reference&&(e=(r.scheme?r.scheme+":":"")+"//"+e);var o=e.match(k);if(o){G?(t.scheme=o[1],t.userinfo=o[3],t.host=o[4],t.port=parseInt(o[5],10),t.path=o[6]||"",t.query=o[7],t.fragment=o[8],isNaN(t.port)&&(t.port=o[5])):(t.scheme=o[1]||undefined,t.userinfo=e.indexOf("@")!==-1?o[3]:undefined,t.host=e.indexOf("//")!==-1?o[4]:undefined,t.port=parseInt(o[5],10),t.path=o[6]||"",t.query=e.indexOf("?")!==-1?o[7]:undefined,t.fragment=e.indexOf("#")!==-1?o[8]:undefined,isNaN(t.port)&&(t.port=e.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/)?o[4]:undefined)),t.host&&(t.host=t.host.replace(n.IPV6ADDRESS,"$1")),t.scheme!==undefined||t.userinfo!==undefined||t.host!==undefined||t.port!==undefined||t.path||t.query!==undefined?t.scheme===undefined?t.reference="relative":t.fragment===undefined?t.reference="absolute":t.reference="uri":t.reference="same-document",r.reference&&"suffix"!==r.reference&&r.reference!==t.reference&&(t.error=t.error||"URI is not a "+r.reference+" reference.");var a=V[(r.scheme||t.scheme||"").toLowerCase()];if(r.unicodeSupport||a&&a.unicodeSupport)d(t,n);else{if(t.host&&(r.domainHost||a&&a.domainHost))try{t.host=Z.toASCII(t.host.replace(n.PCT_ENCODED,h).toLowerCase())}catch(i){t.error=t.error||"Host's domain name can not be converted to ASCII via punycode: "+i}d(t,x)}a&&a.parse&&a.parse(t,r)}else t.error=t.error||"URI can not be parsed.";return t}function g(e,r){var t=r.iri!==!1?w:x,n=[];return e.userinfo!==undefined&&(n.push(e.userinfo),n.push("@")),e.host!==undefined&&n.push(String(e.host).replace(t.IPV6ADDRESS,"[$1]")),"number"==typeof e.port&&(n.push(":"),n.push(e.port.toString(10))),n.length?n.join(""):undefined}function m(e){for(var r=[];e.length;)if(e.match(Q))e=e.replace(Q,"");else if(e.match(Y))e=e.replace(Y,"/");else if(e.match(B))e=e.replace(B,"/"),r.pop();else if("."===e||".."===e)e="";else{var t=e.match(J);if(!t)throw new Error("Unexpected dot segment condition");var n=t[0];e=e.slice(n.length),r.push(n)}return r.join("")}function v(e){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},t=r.iri?w:x,n=[],o=V[(r.scheme||e.scheme||"").toLowerCase()];if(o&&o.serialize&&o.serialize(e,r),e.host)if(t.IPV6ADDRESS.test(e.host));else if(r.domainHost||o&&o.domainHost)try{e.host=r.iri?Z.toUnicode(e.host):Z.toASCII(e.host.replace(t.PCT_ENCODED,h).toLowerCase())}catch(u){e.error=e.error||"Host's domain name can not be converted to "+(r.iri?"Unicode":"ASCII")+" via punycode: "+u}d(e,t),"suffix"!==r.reference&&e.scheme&&(n.push(e.scheme),n.push(":"));var a=g(e,r);if(a!==undefined&&("suffix"!==r.reference&&n.push("//"),n.push(a),e.path&&"/"!==e.path.charAt(0)&&n.push("/")),e.path!==undefined){var i=e.path;r.absolutePath||o&&o.absolutePath||(i=m(i)),a===undefined&&(i=i.replace(/^\/\//,"/%2F")),n.push(i)}return e.query!==undefined&&(n.push("?"),n.push(e.query)),e.fragment!==undefined&&(n.push("#"),n.push(e.fragment)),n.join("")}function E(e,r){var t=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{},n=arguments[3],o={};return n||(e=l(v(e,t),t),r=l(v(r,t),t)),t=t||{},!t.tolerant&&r.scheme?(o.scheme=r.scheme,o.userinfo=r.userinfo,o.host=r.host,o.port=r.port,o.path=m(r.path||""),o.query=r.query):(r.userinfo!==undefined||r.host!==undefined||r.port!==undefined?(o.userinfo=r.userinfo,o.host=r.host,o.port=r.port,o.path=m(r.path||""),o.query=r.query):(r.path?("/"===r.path.charAt(0)?o.path=m(r.path):(e.userinfo===undefined&&e.host===undefined&&e.port===undefined||e.path?e.path?o.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+r.path:o.path=r.path:o.path="/"+r.path,o.path=m(o.path)),o.query=r.query):(o.path=e.path,r.query!==undefined?o.query=r.query:o.query=e.query),o.userinfo=e.userinfo,o.host=e.host,o.port=e.port),o.scheme=e.scheme),o.fragment=r.fragment,o}function C(e,r,t){return v(E(l(e,t),l(r,t),t,!0),t)}function y(e,r){return"string"==typeof e?e=v(l(e,r),r):"object"===n(e)&&(e=l(v(e,r),r)),e}function S(e,r,t){return"string"==typeof e?e=v(l(e,t),t):"object"===n(e)&&(e=v(e,t)),"string"==typeof r?r=v(l(r,t),t):"object"===n(r)&&(r=v(r,t)),e===r}function A(e,r){return e&&e.toString().replace(r&&r.iri?w.ESCAPE:x.ESCAPE,c)}function D(e,r){return e&&e.toString().replace(r&&r.iri?w.PCT_ENCODED:x.PCT_ENCODED,h)}function F(e){var r=h(e);return r.match(oe)?r:e}var x=i(!1),w=i(!0),O=function(e){if(Array.isArray(e)){for(var r=0,t=Array(e.length);r<e.length;r++)t[r]=e[r];return t}return Array.from(e)},b=2147483647,N=/^xn--/,I=/[^\0-\x7E]/,T=/[\x2E\u3002\uFF0E\uFF61]/g,R={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},_=Math.floor,P=String.fromCharCode,U=function(e){return String.fromCodePoint.apply(String,O(e))},q=function(e){return e-48<10?e-22:e-65<26?e-65:e-97<26?e-97:36},H=function(e,r){return e+22+75*(e<26)-((0!=r)<<5)},j=function(e,r,t){var n=0;for(e=t?_(e/700):e>>1,e+=_(e/r);e>455;n+=36)e=_(e/35);return _(n+36*e/(e+38))},z=function(e){var r=[],t=e.length,n=0,o=128,a=72,i=e.lastIndexOf("-");i<0&&(i=0);for(var s=0;s<i;++s)e.charCodeAt(s)>=128&&u("not-basic"),r.push(e.charCodeAt(s));for(var p=i>0?i+1:0;p<t;){for(var f=n,c=1,h=36;;h+=36){p>=t&&u("invalid-input");var d=q(e.charCodeAt(p++));(d>=36||d>_((b-n)/c))&&u("overflow"),n+=d*c;var l=h<=a?1:h>=a+26?26:h-a;if(d<l)break;var g=36-l;c>_(b/g)&&u("overflow"),c*=g}var m=r.length+1;a=j(n-f,m,0==f),_(n/m)>b-o&&u("overflow"),o+=_(n/m),n%=m,r.splice(n++,0,o)}return String.fromCodePoint.apply(String,r)},L=function(e){var r=[];e=f(e);var t=e.length,n=128,o=0,a=72,i=!0,s=!1,p=undefined;try{for(var c,h=e[Symbol.iterator]();!(i=(c=h.next()).done);i=!0){var d=c.value;d<128&&r.push(P(d))}}catch(L){s=!0,p=L}finally{try{!i&&h["return"]&&h["return"]()}finally{if(s)throw p}}var l=r.length,g=l;for(l&&r.push("-");g<t;){var m=b,v=!0,E=!1,C=undefined;try{for(var y,S=e[Symbol.iterator]();!(v=(y=S.next()).done);v=!0){var A=y.value;A>=n&&A<m&&(m=A)}}catch(L){E=!0,C=L}finally{try{!v&&S["return"]&&S["return"]()}finally{if(E)throw C}}var D=g+1;m-n>_((b-o)/D)&&u("overflow"),o+=(m-n)*D,n=m;var F=!0,x=!1,w=undefined;try{for(var O,N=e[Symbol.iterator]();!(F=(O=N.next()).done);F=!0){var I=O.value;if(I<n&&++o>b&&u("overflow"),I==n){for(var T=o,R=36;;R+=36){var U=R<=a?1:R>=a+26?26:R-a;if(T<U)break;var q=T-U,z=36-U;r.push(P(H(U+q%z,0))),T=_(q/z)}r.push(P(H(T,0))),a=j(o,D,g==l),o=0,++g}}}catch(L){x=!0,w=L}finally{try{!F&&N["return"]&&N["return"]()}finally{if(x)throw w}}++o,++n}return r.join("")},$=function(e){return p(e,function(e){return N.test(e)?z(e.slice(4).toLowerCase()):e})},M=function(e){return p(e,function(e){return I.test(e)?"xn--"+L(e):e})},Z={version:"2.1.0",ucs2:{decode:f,encode:U},decode:z,encode:L,toASCII:M,toUnicode:$},V={},k=/^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[\dA-F:.]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i,G="".match(/(){0}/)[1]===undefined,Q=/^\.\.?\//,Y=/^\/\.(\/|$)/,B=/^\/\.\.(\/|$)/,J=/^\/?(?:.|\n)*?(?=\/|$)/,K={scheme:"http",domainHost:!0,parse:function(e,r){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e},serialize:function(e,r){return e.port!==("https"!==String(e.scheme).toLowerCase()?80:443)&&""!==e.port||(e.port=undefined),e.path||(e.path="/"),e}},W={scheme:"https",domainHost:K.domainHost,parse:K.parse,serialize:K.serialize},X={},ee="[A-Za-z0-9\\-\\.\\_\\~\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]",re="[0-9A-Fa-f]",te=t(t("%[EFef][0-9A-Fa-f]%"+re+re+"%"+re+re)+"|"+t("%[89A-Fa-f][0-9A-Fa-f]%"+re+re)+"|"+t("%"+re+re)),ne=r("[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]",'[\\"\\\\]'),oe=new RegExp(ee,"g"),ae=new RegExp(te,"g"),ie=new RegExp(r("[^]","[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]","[\\.]",'[\\"]',ne),"g"),ue=new RegExp(r("[^]",ee,"[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]"),"g"),se=ue,pe={scheme:"mailto",parse:function(e,r){var t=e.to=e.path?e.path.split(","):[];if(e.path=undefined,e.query){for(var n=!1,o={},a=e.query.split("&"),i=0,u=a.length;i<u;++i){var s=a[i].split("=");switch(s[0]){case"to":for(var p=s[1].split(","),f=0,c=p.length;f<c;++f)t.push(p[f]);break;case"subject":e.subject=D(s[1],r);break;case"body":e.body=D(s[1],r);break;default:n=!0,o[D(s[0],r)]=D(s[1],r)}}n&&(e.headers=o)}e.query=undefined;for(var h=0,d=t.length;h<d;++h){var l=t[h].split("@");if(l[0]=D(l[0]),r.unicodeSupport)l[1]=D(l[1],r).toLowerCase();else try{l[1]=Z.toASCII(D(l[1],r).toLowerCase())}catch(g){e.error=e.error||"Email address's domain name can not be converted to ASCII via punycode: "+g}t[h]=l.join("@")}return e},serialize:function(e,r){var t=a(e.to);if(t){for(var n=0,i=t.length;n<i;++n){var u=String(t[n]),s=u.lastIndexOf("@"),p=u.slice(0,s).replace(ae,F).replace(ae,o).replace(ie,c),f=u.slice(s+1);try{f=r.iri?Z.toUnicode(f):Z.toASCII(D(f,r).toLowerCase())}catch(g){e.error=e.error||"Email address's domain name can not be converted to "+(r.iri?"Unicode":"ASCII")+" via punycode: "+g}t[n]=p+"@"+f}e.path=t.join(",")}var h=e.headers=e.headers||{};e.subject&&(h.subject=e.subject),e.body&&(h.body=e.body);var d=[];for(var l in h)h[l]!==X[l]&&d.push(l.replace(ae,F).replace(ae,o).replace(ue,c)+"="+h[l].replace(ae,F).replace(ae,o).replace(se,c));return d.length&&(e.query=d.join("&")),e}},fe=new RegExp("^urn\\:((?:[0-9A-Za-z][0-9A-Za-z\\-]{1,31}))$"),ce={scheme:"urn",parse:function(e,r){var t=e.path&&e.path.match(/^([^\:]+)\:(.*)/);if(t){var n="urn:"+t[1].toLowerCase(),o=V[n];o||(o=V[n]={scheme:n,parse:function(e,r){return e},serialize:V.urn.serialize}),e.scheme=n,e.path=t[2],e=o.parse(e,r)}else e.error=e.error||"URN can not be parsed.";return e},serialize:function(e,r){var t=e.scheme||r.scheme;if(t&&"urn"!==t){var n=t.match(fe)||["urn:"+t,t];e.scheme="urn",e.path=n[1]+":"+(e.path?e.path.replace(/[\x00-\x20\\\"\&\<\>\[\]\^\`\{\|\}\~\x7F-\xFF]/g,c):"")}return e}},he=/^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/,de={scheme:"urn:uuid",parse:function(e,r){return r.tolerant||e.path&&e.path.match(he)||(e.error=e.error||"UUID is not valid."),e},serialize:function(e,r){return r.tolerant||e.path&&e.path.match(he)?e.path=(e.path||"").toLowerCase():e.scheme=undefined,V.urn.serialize(e,r)}};V.http=K,V.https=W,V.mailto=pe,V.urn=ce,V["urn:uuid"]=de,e.SCHEMES=V,e.pctEncChar=c,e.pctDecChars=h,e.parse=l,e.removeDotSegments=m,e.serialize=v,e.resolveComponents=E,e.resolve=C,e.normalize=y,e.equal=S,e.escapeComponent=A,e.unescapeComponent=D,Object.defineProperty(e,"__esModule",{value:!0})});
/** @license URI.js v4.1.0 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(e.URI=e.URI||{})}(this,function(e){"use strict";function r(){for(var e=arguments.length,r=Array(e),n=0;n<e;n++)r[n]=arguments[n];if(r.length>1){r[0]=r[0].slice(0,-1);for(var t=r.length-1,o=1;o<t;++o)r[o]=r[o].slice(1,-1);return r[t]=r[t].slice(1),r.join("")}return r[0]}function n(e){return"(?:"+e+")"}function t(e){return e===undefined?"undefined":null===e?"null":Object.prototype.toString.call(e).split(" ").pop().split("]").shift().toLowerCase()}function o(e){return e.toUpperCase()}function a(e){return e!==undefined&&null!==e?e instanceof Array?e:"number"!=typeof e.length||e.split||e.setInterval||e.call?[e]:Array.prototype.slice.call(e):[]}function i(e){var t=r("[0-9]","[A-Fa-f]"),o=n(n("%[EFef]"+t+"%"+t+t+"%"+t+t)+"|"+n("%[89A-Fa-f]"+t+"%"+t+t)+"|"+n("%"+t+t)),a="[\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=]",i=r("[\\:\\/\\?\\#\\[\\]\\@]",a),u=e?"[\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]":"[]",s=e?"[\\uE000-\\uF8FF]":"[]",f=r("[A-Za-z]","[0-9]","[\\-\\.\\_\\~]",u),c=n(n("25[0-5]")+"|"+n("2[0-4][0-9]")+"|"+n("1[0-9][0-9]")+"|"+n("0?[1-9][0-9]")+"|0?0?[0-9]"),p=n(c+"\\."+c+"\\."+c+"\\."+c),h=n(t+"{1,4}"),d=n(n(h+"\\:"+h)+"|"+p),l=n(n(h+"\\:")+"{6}"+d),g=n("\\:\\:"+n(h+"\\:")+"{5}"+d),v=n(n(h)+"?\\:\\:"+n(h+"\\:")+"{4}"+d),m=n(n(n(h+"\\:")+"{0,1}"+h)+"?\\:\\:"+n(h+"\\:")+"{3}"+d),E=n(n(n(h+"\\:")+"{0,2}"+h)+"?\\:\\:"+n(h+"\\:")+"{2}"+d),C=n(n(n(h+"\\:")+"{0,3}"+h)+"?\\:\\:"+h+"\\:"+d),y=n(n(n(h+"\\:")+"{0,4}"+h)+"?\\:\\:"+d),S=n(n(n(h+"\\:")+"{0,5}"+h)+"?\\:\\:"+h),A=n(n(n(h+"\\:")+"{0,6}"+h)+"?\\:\\:"),D=n([l,g,v,m,E,C,y,S,A].join("|")),w=n(n(f+"|"+o)+"+");return{NOT_SCHEME:new RegExp(r("[^]","[A-Za-z]","[0-9]","[\\+\\-\\.]"),"g"),NOT_USERINFO:new RegExp(r("[^\\%\\:]",f,a),"g"),NOT_HOST:new RegExp(r("[^\\%\\[\\]\\:]",f,a),"g"),NOT_PATH:new RegExp(r("[^\\%\\/\\:\\@]",f,a),"g"),NOT_PATH_NOSCHEME:new RegExp(r("[^\\%\\/\\@]",f,a),"g"),NOT_QUERY:new RegExp(r("[^\\%]",f,a,"[\\:\\@\\/\\?]",s),"g"),NOT_FRAGMENT:new RegExp(r("[^\\%]",f,a,"[\\:\\@\\/\\?]"),"g"),ESCAPE:new RegExp(r("[^]",f,a),"g"),UNRESERVED:new RegExp(f,"g"),OTHER_CHARS:new RegExp(r("[^\\%]",f,i),"g"),PCT_ENCODED:new RegExp(o,"g"),IPV4ADDRESS:new RegExp("^("+p+")$"),IPV6ADDRESS:new RegExp("^\\[?("+D+")"+n(n("\\%25|\\%(?!"+t+"{2})")+"("+w+")")+"?\\]?$")}}function u(e){throw new RangeError(j[e])}function s(e,r){for(var n=[],t=e.length;t--;)n[t]=r(e[t]);return n}function f(e,r){var n=e.split("@"),t="";return n.length>1&&(t=n[0]+"@",e=n[1]),e=e.replace(U,"."),t+s(e.split("."),r).join(".")}function c(e){for(var r=[],n=0,t=e.length;n<t;){var o=e.charCodeAt(n++);if(o>=55296&&o<=56319&&n<t){var a=e.charCodeAt(n++);56320==(64512&a)?r.push(((1023&o)<<10)+(1023&a)+65536):(r.push(o),n--)}else r.push(o)}return r}function p(e){var r=e.charCodeAt(0);return r<16?"%0"+r.toString(16).toUpperCase():r<128?"%"+r.toString(16).toUpperCase():r<2048?"%"+(r>>6|192).toString(16).toUpperCase()+"%"+(63&r|128).toString(16).toUpperCase():"%"+(r>>12|224).toString(16).toUpperCase()+"%"+(r>>6&63|128).toString(16).toUpperCase()+"%"+(63&r|128).toString(16).toUpperCase()}function h(e){for(var r="",n=0,t=e.length;n<t;){var o=parseInt(e.substr(n+1,2),16);if(o<128)r+=String.fromCharCode(o),n+=3;else if(o>=194&&o<224){if(t-n>=6){var a=parseInt(e.substr(n+4,2),16);r+=String.fromCharCode((31&o)<<6|63&a)}else r+=e.substr(n,6);n+=6}else if(o>=224){if(t-n>=9){var i=parseInt(e.substr(n+4,2),16),u=parseInt(e.substr(n+7,2),16);r+=String.fromCharCode((15&o)<<12|(63&i)<<6|63&u)}else r+=e.substr(n,9);n+=9}else r+=e.substr(n,3),n+=3}return r}function d(e,r){function n(e){var n=h(e);return n.match(r.UNRESERVED)?n:e}return e.scheme&&(e.scheme=String(e.scheme).replace(r.PCT_ENCODED,n).toLowerCase().replace(r.NOT_SCHEME,"")),e.userinfo!==undefined&&(e.userinfo=String(e.userinfo).replace(r.PCT_ENCODED,n).replace(r.NOT_USERINFO,p).replace(r.PCT_ENCODED,o)),e.host!==undefined&&(e.host=String(e.host).replace(r.PCT_ENCODED,n).toLowerCase().replace(r.NOT_HOST,p).replace(r.PCT_ENCODED,o)),e.path!==undefined&&(e.path=String(e.path).replace(r.PCT_ENCODED,n).replace(e.scheme?r.NOT_PATH:r.NOT_PATH_NOSCHEME,p).replace(r.PCT_ENCODED,o)),e.query!==undefined&&(e.query=String(e.query).replace(r.PCT_ENCODED,n).replace(r.NOT_QUERY,p).replace(r.PCT_ENCODED,o)),e.fragment!==undefined&&(e.fragment=String(e.fragment).replace(r.PCT_ENCODED,n).replace(r.NOT_FRAGMENT,p).replace(r.PCT_ENCODED,o)),e}function l(e){return e.replace(/^0*(.*)/,"$1")||"0"}function g(e,r){var n=e.match(r.IPV4ADDRESS)||[],t=N(n,2),o=t[1];return o?o.split(".").map(l).join("."):e}function v(e,r){var n=e.match(r.IPV6ADDRESS)||[],t=N(n,3),o=t[1],a=t[2];if(o){for(var i=o.toLowerCase().split("::").reverse(),u=N(i,2),s=u[0],f=u[1],c=f?f.split(":").map(l):[],p=s.split(":").map(l),h=r.IPV4ADDRESS.test(p[p.length-1]),d=h?7:8,v=p.length-d,m=Array(d),E=0;E<d;++E)m[E]=c[E]||p[v+E]||"";h&&(m[d-1]=g(m[d-1],r));var C=m.reduce(function(e,r,n){if(!r||"0"===r){var t=e[e.length-1];t&&t.index+t.length===n?t.length++:e.push({index:n,length:1})}return e},[]),y=C.sort(function(e,r){return r.length-e.length})[0],S=void 0;if(y&&y.length>1){var A=m.slice(0,y.index),D=m.slice(y.index+y.length);S=A.join(":")+"::"+D.join(":")}else S=m.join(":");return a&&(S+="%"+a),S}return e}function m(e){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},n={},t=!1!==r.iri?F:I;"suffix"===r.reference&&(e=(r.scheme?r.scheme+":":"")+"//"+e);var o=e.match(B);if(o){J?(n.scheme=o[1],n.userinfo=o[3],n.host=o[4],n.port=parseInt(o[5],10),n.path=o[6]||"",n.query=o[7],n.fragment=o[8],isNaN(n.port)&&(n.port=o[5])):(n.scheme=o[1]||undefined,n.userinfo=-1!==e.indexOf("@")?o[3]:undefined,n.host=-1!==e.indexOf("//")?o[4]:undefined,n.port=parseInt(o[5],10),n.path=o[6]||"",n.query=-1!==e.indexOf("?")?o[7]:undefined,n.fragment=-1!==e.indexOf("#")?o[8]:undefined,isNaN(n.port)&&(n.port=e.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/)?o[4]:undefined)),n.host&&(n.host=v(g(n.host,t),t)),n.scheme!==undefined||n.userinfo!==undefined||n.host!==undefined||n.port!==undefined||n.path||n.query!==undefined?n.scheme===undefined?n.reference="relative":n.fragment===undefined?n.reference="absolute":n.reference="uri":n.reference="same-document",r.reference&&"suffix"!==r.reference&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");var a=Y[(r.scheme||n.scheme||"").toLowerCase()];if(r.unicodeSupport||a&&a.unicodeSupport)d(n,t);else{if(n.host&&(r.domainHost||a&&a.domainHost))try{n.host=Q.toASCII(n.host.replace(t.PCT_ENCODED,h).toLowerCase())}catch(i){n.error=n.error||"Host's domain name can not be converted to ASCII via punycode: "+i}d(n,I)}a&&a.parse&&a.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return n}function E(e,r){var n=!1!==r.iri?F:I,t=[];return e.userinfo!==undefined&&(t.push(e.userinfo),t.push("@")),e.host!==undefined&&t.push(v(g(String(e.host),n),n).replace(n.IPV6ADDRESS,function(e,r,n){return"["+r+(n?"%25"+n:"")+"]"})),"number"==typeof e.port&&(t.push(":"),t.push(e.port.toString(10))),t.length?t.join(""):undefined}function C(e){for(var r=[];e.length;)if(e.match(K))e=e.replace(K,"");else if(e.match(W))e=e.replace(W,"/");else if(e.match(X))e=e.replace(X,"/"),r.pop();else if("."===e||".."===e)e="";else{var n=e.match(ee);if(!n)throw new Error("Unexpected dot segment condition");var t=n[0];e=e.slice(t.length),r.push(t)}return r.join("")}function y(e){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},n=r.iri?F:I,t=[],o=Y[(r.scheme||e.scheme||"").toLowerCase()];if(o&&o.serialize&&o.serialize(e,r),e.host)if(n.IPV6ADDRESS.test(e.host));else if(r.domainHost||o&&o.domainHost)try{e.host=r.iri?Q.toUnicode(e.host):Q.toASCII(e.host.replace(n.PCT_ENCODED,h).toLowerCase())}catch(u){e.error=e.error||"Host's domain name can not be converted to "+(r.iri?"Unicode":"ASCII")+" via punycode: "+u}d(e,n),"suffix"!==r.reference&&e.scheme&&(t.push(e.scheme),t.push(":"));var a=E(e,r);if(a!==undefined&&("suffix"!==r.reference&&t.push("//"),t.push(a),e.path&&"/"!==e.path.charAt(0)&&t.push("/")),e.path!==undefined){var i=e.path;r.absolutePath||o&&o.absolutePath||(i=C(i)),a===undefined&&(i=i.replace(/^\/\//,"/%2F")),t.push(i)}return e.query!==undefined&&(t.push("?"),t.push(e.query)),e.fragment!==undefined&&(t.push("#"),t.push(e.fragment)),t.join("")}function S(e,r){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{},t=arguments[3],o={};return t||(e=m(y(e,n),n),r=m(y(r,n),n)),n=n||{},!n.tolerant&&r.scheme?(o.scheme=r.scheme,o.userinfo=r.userinfo,o.host=r.host,o.port=r.port,o.path=C(r.path||""),o.query=r.query):(r.userinfo!==undefined||r.host!==undefined||r.port!==undefined?(o.userinfo=r.userinfo,o.host=r.host,o.port=r.port,o.path=C(r.path||""),o.query=r.query):(r.path?("/"===r.path.charAt(0)?o.path=C(r.path):(e.userinfo===undefined&&e.host===undefined&&e.port===undefined||e.path?e.path?o.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+r.path:o.path=r.path:o.path="/"+r.path,o.path=C(o.path)),o.query=r.query):(o.path=e.path,r.query!==undefined?o.query=r.query:o.query=e.query),o.userinfo=e.userinfo,o.host=e.host,o.port=e.port),o.scheme=e.scheme),o.fragment=r.fragment,o}function A(e,r,n){return y(S(m(e,n),m(r,n),n,!0),n)}function D(e,r){return"string"==typeof e?e=y(m(e,r),r):"object"===t(e)&&(e=m(y(e,r),r)),e}function w(e,r,n){return"string"==typeof e?e=y(m(e,n),n):"object"===t(e)&&(e=y(e,n)),"string"==typeof r?r=y(m(r,n),n):"object"===t(r)&&(r=y(r,n)),e===r}function b(e,r){return e&&e.toString().replace(r&&r.iri?F.ESCAPE:I.ESCAPE,p)}function x(e,r){return e&&e.toString().replace(r&&r.iri?F.PCT_ENCODED:I.PCT_ENCODED,h)}function O(e){var r=h(e);return r.match(se)?r:e}var I=i(!1),F=i(!0),N=function(){function e(e,r){var n=[],t=!0,o=!1,a=undefined;try{for(var i,u=e[Symbol.iterator]();!(t=(i=u.next()).done)&&(n.push(i.value),!r||n.length!==r);t=!0);}catch(s){o=!0,a=s}finally{try{!t&&u["return"]&&u["return"]()}finally{if(o)throw a}}return n}return function(r,n){if(Array.isArray(r))return r;if(Symbol.iterator in Object(r))return e(r,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),R=function(e){if(Array.isArray(e)){for(var r=0,n=Array(e.length);r<e.length;r++)n[r]=e[r];return n}return Array.from(e)},T=2147483647,_=/^xn--/,P=/[^\0-\x7E]/,U=/[\x2E\u3002\uFF0E\uFF61]/g,j={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},q=Math.floor,H=String.fromCharCode,z=function(e){return String.fromCodePoint.apply(String,R(e))},L=function(e){return e-48<10?e-22:e-65<26?e-65:e-97<26?e-97:36},$=function(e,r){return e+22+75*(e<26)-((0!=r)<<5)},M=function(e,r,n){var t=0;for(e=n?q(e/700):e>>1,e+=q(e/r);e>455;t+=36)e=q(e/35);return q(t+36*e/(e+38))},V=function(e){var r=[],n=e.length,t=0,o=128,a=72,i=e.lastIndexOf("-");i<0&&(i=0);for(var s=0;s<i;++s)e.charCodeAt(s)>=128&&u("not-basic"),r.push(e.charCodeAt(s));for(var f=i>0?i+1:0;f<n;){for(var c=t,p=1,h=36;;h+=36){f>=n&&u("invalid-input");var d=L(e.charCodeAt(f++));(d>=36||d>q((T-t)/p))&&u("overflow"),t+=d*p;var l=h<=a?1:h>=a+26?26:h-a;if(d<l)break;var g=36-l;p>q(T/g)&&u("overflow"),p*=g}var v=r.length+1;a=M(t-c,v,0==c),q(t/v)>T-o&&u("overflow"),o+=q(t/v),t%=v,r.splice(t++,0,o)}return String.fromCodePoint.apply(String,r)},k=function(e){var r=[];e=c(e);var n=e.length,t=128,o=0,a=72,i=!0,s=!1,f=undefined;try{for(var p,h=e[Symbol.iterator]();!(i=(p=h.next()).done);i=!0){var d=p.value;d<128&&r.push(H(d))}}catch(j){s=!0,f=j}finally{try{!i&&h["return"]&&h["return"]()}finally{if(s)throw f}}var l=r.length,g=l;for(l&&r.push("-");g<n;){var v=T,m=!0,E=!1,C=undefined;try{for(var y,S=e[Symbol.iterator]();!(m=(y=S.next()).done);m=!0){var A=y.value;A>=t&&A<v&&(v=A)}}catch(j){E=!0,C=j}finally{try{!m&&S["return"]&&S["return"]()}finally{if(E)throw C}}var D=g+1;v-t>q((T-o)/D)&&u("overflow"),o+=(v-t)*D,t=v;var w=!0,b=!1,x=undefined;try{for(var O,I=e[Symbol.iterator]();!(w=(O=I.next()).done);w=!0){var F=O.value;if(F<t&&++o>T&&u("overflow"),F==t){for(var N=o,R=36;;R+=36){var _=R<=a?1:R>=a+26?26:R-a;if(N<_)break;var P=N-_,U=36-_;r.push(H($(_+P%U,0))),N=q(P/U)}r.push(H($(N,0))),a=M(o,D,g==l),o=0,++g}}}catch(j){b=!0,x=j}finally{try{!w&&I["return"]&&I["return"]()}finally{if(b)throw x}}++o,++t}return r.join("")},Z=function(e){return f(e,function(e){return _.test(e)?V(e.slice(4).toLowerCase()):e})},G=function(e){return f(e,function(e){return P.test(e)?"xn--"+k(e):e})},Q={version:"2.1.0",ucs2:{decode:c,encode:z},decode:V,encode:k,toASCII:G,toUnicode:Z},Y={},B=/^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i,J="".match(/(){0}/)[1]===undefined,K=/^\.\.?\//,W=/^\/\.(\/|$)/,X=/^\/\.\.(\/|$)/,ee=/^\/?(?:.|\n)*?(?=\/|$)/,re={scheme:"http",domainHost:!0,parse:function(e,r){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e},serialize:function(e,r){return e.port!==("https"!==String(e.scheme).toLowerCase()?80:443)&&""!==e.port||(e.port=undefined),e.path||(e.path="/"),e}},ne={scheme:"https",domainHost:re.domainHost,parse:re.parse,serialize:re.serialize},te={},oe="[A-Za-z0-9\\-\\.\\_\\~\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]",ae="[0-9A-Fa-f]",ie=n(n("%[EFef][0-9A-Fa-f]%"+ae+ae+"%"+ae+ae)+"|"+n("%[89A-Fa-f][0-9A-Fa-f]%"+ae+ae)+"|"+n("%"+ae+ae)),ue=r("[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]",'[\\"\\\\]'),se=new RegExp(oe,"g"),fe=new RegExp(ie,"g"),ce=new RegExp(r("[^]","[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]","[\\.]",'[\\"]',ue),"g"),pe=new RegExp(r("[^]",oe,"[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]"),"g"),he=pe,de={scheme:"mailto",parse:function(e,r){var n=e,t=n.to=n.path?n.path.split(","):[];if(n.path=undefined,n.query){for(var o=!1,a={},i=n.query.split("&"),u=0,s=i.length;u<s;++u){var f=i[u].split("=");switch(f[0]){case"to":for(var c=f[1].split(","),p=0,h=c.length;p<h;++p)t.push(c[p]);break;case"subject":n.subject=x(f[1],r);break;case"body":n.body=x(f[1],r);break;default:o=!0,a[x(f[0],r)]=x(f[1],r)}}o&&(n.headers=a)}n.query=undefined;for(var d=0,l=t.length;d<l;++d){var g=t[d].split("@");if(g[0]=x(g[0]),r.unicodeSupport)g[1]=x(g[1],r).toLowerCase();else try{g[1]=Q.toASCII(x(g[1],r).toLowerCase())}catch(v){n.error=n.error||"Email address's domain name can not be converted to ASCII via punycode: "+v}t[d]=g.join("@")}return n},serialize:function(e,r){var n=e,t=a(e.to);if(t){for(var i=0,u=t.length;i<u;++i){var s=String(t[i]),f=s.lastIndexOf("@"),c=s.slice(0,f).replace(fe,O).replace(fe,o).replace(ce,p),h=s.slice(f+1);try{h=r.iri?Q.toUnicode(h):Q.toASCII(x(h,r).toLowerCase())}catch(v){n.error=n.error||"Email address's domain name can not be converted to "+(r.iri?"Unicode":"ASCII")+" via punycode: "+v}t[i]=c+"@"+h}n.path=t.join(",")}var d=e.headers=e.headers||{};e.subject&&(d.subject=e.subject),e.body&&(d.body=e.body);var l=[];for(var g in d)d[g]!==te[g]&&l.push(g.replace(fe,O).replace(fe,o).replace(pe,p)+"="+d[g].replace(fe,O).replace(fe,o).replace(he,p));return l.length&&(n.query=l.join("&")),n}},le=/^([^\:]+)\:(.*)/,ge={scheme:"urn",parse:function(e,r){var n=e.path&&e.path.match(le),t=e;if(n){var o=r.scheme||t.scheme||"urn",a=n[1].toLowerCase(),i=n[2],u=o+":"+(r.nid||a),s=Y[u];t.nid=a,t.nss=i,t.path=undefined,s&&(t=s.parse(t,r))}else t.error=t.error||"URN can not be parsed.";return t},serialize:function(e,r){var n=r.scheme||e.scheme||"urn",t=e.nid,o=n+":"+(r.nid||t),a=Y[o];a&&(e=a.serialize(e,r));var i=e,u=e.nss;return i.path=(t||r.nid)+":"+u,i}},ve=/^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/,me={scheme:"urn:uuid",parse:function(e,r){var n=e;return n.uuid=n.nss,n.nss=undefined,r.tolerant||n.uuid&&n.uuid.match(ve)||(n.error=n.error||"UUID is not valid."),n},serialize:function(e,r){var n=e;return n.nss=(e.uuid||"").toLowerCase(),n}};Y[re.scheme]=re,Y[ne.scheme]=ne,Y[de.scheme]=de,Y[ge.scheme]=ge,Y[me.scheme]=me,e.SCHEMES=Y,e.pctEncChar=p,e.pctDecChars=h,e.parse=m,e.removeDotSegments=C,e.serialize=y,e.resolveComponents=S,e.resolve=A,e.normalize=D,e.equal=w,e.escapeComponent=b,e.unescapeComponent=x,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=uri.all.min.js.map
import { SCHEMES } from "./uri";
import http from "./schemes/http";
SCHEMES["http"] = http;
SCHEMES[http.scheme] = http;
import https from "./schemes/https";
SCHEMES["https"] = https;
SCHEMES[https.scheme] = https;
import mailto from "./schemes/mailto";
SCHEMES["mailto"] = mailto;
SCHEMES[mailto.scheme] = mailto;
import urn from "./schemes/urn";
SCHEMES["urn"] = urn;
SCHEMES[urn.scheme] = urn;
import uuid from "./schemes/urn-uuid";
SCHEMES["urn:uuid"] = uuid;
SCHEMES[uuid.scheme] = uuid;
export * from "./uri";
//# sourceMappingURL=index.js.map
import { URIRegExps } from "./uri";
declare var _default: URIRegExps;
declare const _default: URIRegExps;
export default _default;
import { URIRegExps } from "./uri";
export declare function buildExps(isIRI: boolean): URIRegExps;
declare var _default: URIRegExps;
declare const _default: URIRegExps;
export default _default;

@@ -7,3 +7,4 @@ import { merge, subexp } from "./util";

IPRIVATE$$ = isIRI ? "[\\uE000-\\uF8FF]" : "[]", //subset
UNRESERVED$$ = merge(ALPHA$$, DIGIT$$, "[\\-\\.\\_\\~]", UCSCHAR$$), SCHEME$ = subexp(ALPHA$$ + merge(ALPHA$$, DIGIT$$, "[\\+\\-\\.]") + "*"), USERINFO$ = subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:]")) + "*"), DEC_OCTET$ = subexp(subexp("25[0-5]") + "|" + subexp("2[0-4]" + DIGIT$$) + "|" + subexp("1" + DIGIT$$ + DIGIT$$) + "|" + subexp("[1-9]" + DIGIT$$) + "|" + DIGIT$$), IPV4ADDRESS$ = subexp(DEC_OCTET$ + "\\." + DEC_OCTET$ + "\\." + DEC_OCTET$ + "\\." + DEC_OCTET$), H16$ = subexp(HEXDIG$$ + "{1,4}"), LS32$ = subexp(subexp(H16$ + "\\:" + H16$) + "|" + IPV4ADDRESS$), IPV6ADDRESS1$ = subexp(subexp(H16$ + "\\:") + "{6}" + LS32$), // 6( h16 ":" ) ls32
UNRESERVED$$ = merge(ALPHA$$, DIGIT$$, "[\\-\\.\\_\\~]", UCSCHAR$$), SCHEME$ = subexp(ALPHA$$ + merge(ALPHA$$, DIGIT$$, "[\\+\\-\\.]") + "*"), USERINFO$ = subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:]")) + "*"), DEC_OCTET$ = subexp(subexp("25[0-5]") + "|" + subexp("2[0-4]" + DIGIT$$) + "|" + subexp("1" + DIGIT$$ + DIGIT$$) + "|" + subexp("[1-9]" + DIGIT$$) + "|" + DIGIT$$), DEC_OCTET_RELAXED$ = subexp(subexp("25[0-5]") + "|" + subexp("2[0-4]" + DIGIT$$) + "|" + subexp("1" + DIGIT$$ + DIGIT$$) + "|" + subexp("0?[1-9]" + DIGIT$$) + "|0?0?" + DIGIT$$), //relaxed parsing rules
IPV4ADDRESS$ = subexp(DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$), H16$ = subexp(HEXDIG$$ + "{1,4}"), LS32$ = subexp(subexp(H16$ + "\\:" + H16$) + "|" + IPV4ADDRESS$), IPV6ADDRESS1$ = subexp(subexp(H16$ + "\\:") + "{6}" + LS32$), // 6( h16 ":" ) ls32
IPV6ADDRESS2$ = subexp("\\:\\:" + subexp(H16$ + "\\:") + "{5}" + LS32$), // "::" 5( h16 ":" ) ls32

@@ -17,3 +18,7 @@ IPV6ADDRESS3$ = subexp(subexp(H16$) + "?\\:\\:" + subexp(H16$ + "\\:") + "{4}" + LS32$), //[ h16 ] "::" 4( h16 ":" ) ls32

IPV6ADDRESS9$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,6}" + H16$) + "?\\:\\:"), //[ *6( h16 ":" ) h16 ] "::"
IPV6ADDRESS$ = subexp([IPV6ADDRESS1$, IPV6ADDRESS2$, IPV6ADDRESS3$, IPV6ADDRESS4$, IPV6ADDRESS5$, IPV6ADDRESS6$, IPV6ADDRESS7$, IPV6ADDRESS8$, IPV6ADDRESS9$].join("|")), IPVFUTURE$ = subexp("[vV]" + HEXDIG$$ + "+\\." + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:]") + "+"), IP_LITERAL$ = subexp("\\[" + subexp(IPV6ADDRESS$ + "|" + IPVFUTURE$) + "\\]"), REG_NAME$ = subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$)) + "*"), HOST$ = subexp(IP_LITERAL$ + "|" + IPV4ADDRESS$ + "(?!" + REG_NAME$ + ")" + "|" + REG_NAME$), PORT$ = subexp(DIGIT$$ + "*"), AUTHORITY$ = subexp(subexp(USERINFO$ + "@") + "?" + HOST$ + subexp("\\:" + PORT$) + "?"), PCHAR$ = subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@]")), SEGMENT$ = subexp(PCHAR$ + "*"), SEGMENT_NZ$ = subexp(PCHAR$ + "+"), SEGMENT_NZ_NC$ = subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\@]")) + "+"), PATH_ABEMPTY$ = subexp(subexp("\\/" + SEGMENT$) + "*"), PATH_ABSOLUTE$ = subexp("\\/" + subexp(SEGMENT_NZ$ + PATH_ABEMPTY$) + "?"), //simplified
IPV6ADDRESS$ = subexp([IPV6ADDRESS1$, IPV6ADDRESS2$, IPV6ADDRESS3$, IPV6ADDRESS4$, IPV6ADDRESS5$, IPV6ADDRESS6$, IPV6ADDRESS7$, IPV6ADDRESS8$, IPV6ADDRESS9$].join("|")), ZONEID$ = subexp(subexp(UNRESERVED$$ + "|" + PCT_ENCODED$) + "+"), //RFC 6874
IPV6ADDRZ$ = subexp(IPV6ADDRESS$ + "\\%25" + ZONEID$), //RFC 6874
IPV6ADDRZ_RELAXED$ = subexp(IPV6ADDRESS$ + subexp("\\%25|\\%(?!" + HEXDIG$$ + "{2})") + ZONEID$), //RFC 6874, with relaxed parsing rules
IPVFUTURE$ = subexp("[vV]" + HEXDIG$$ + "+\\." + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:]") + "+"), IP_LITERAL$ = subexp("\\[" + subexp(IPV6ADDRZ_RELAXED$ + "|" + IPV6ADDRESS$ + "|" + IPVFUTURE$) + "\\]"), //RFC 6874
REG_NAME$ = subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$)) + "*"), HOST$ = subexp(IP_LITERAL$ + "|" + IPV4ADDRESS$ + "(?!" + REG_NAME$ + ")" + "|" + REG_NAME$), PORT$ = subexp(DIGIT$$ + "*"), AUTHORITY$ = subexp(subexp(USERINFO$ + "@") + "?" + HOST$ + subexp("\\:" + PORT$) + "?"), PCHAR$ = subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@]")), SEGMENT$ = subexp(PCHAR$ + "*"), SEGMENT_NZ$ = subexp(PCHAR$ + "+"), SEGMENT_NZ_NC$ = subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\@]")) + "+"), PATH_ABEMPTY$ = subexp(subexp("\\/" + SEGMENT$) + "*"), PATH_ABSOLUTE$ = subexp("\\/" + subexp(SEGMENT_NZ$ + PATH_ABEMPTY$) + "?"), //simplified
PATH_NOSCHEME$ = subexp(SEGMENT_NZ_NC$ + PATH_ABEMPTY$), //simplified

@@ -34,3 +39,4 @@ PATH_ROOTLESS$ = subexp(SEGMENT_NZ$ + PATH_ABEMPTY$), //simplified

PCT_ENCODED: new RegExp(PCT_ENCODED$, "g"),
IPV6ADDRESS: new RegExp("\\[?(" + IPV6ADDRESS$ + ")\\]?", "g")
IPV4ADDRESS: new RegExp("^(" + IPV4ADDRESS$ + ")$"),
IPV6ADDRESS: new RegExp("^\\[?(" + IPV6ADDRESS$ + ")" + subexp(subexp("\\%25|\\%(?!" + HEXDIG$$ + "{2})") + "(" + ZONEID$ + ")") + "?\\]?$") //RFC 6874, with relaxed parsing rules
};

@@ -37,0 +43,0 @@ }

@@ -1,8 +0,3 @@

import { URIComponents, URIOptions } from "../uri";
declare var _default: {
scheme: string;
domainHost: boolean;
parse: (components: URIComponents, options: URIOptions) => URIComponents;
serialize: (components: URIComponents, options: URIOptions) => URIComponents;
};
export default _default;
import { URISchemeHandler } from "../uri";
declare const handler: URISchemeHandler;
export default handler;

@@ -1,2 +0,2 @@

export default {
const handler = {
scheme: "http",

@@ -26,2 +26,3 @@ domainHost: true,

};
export default handler;
//# sourceMappingURL=http.js.map

@@ -1,8 +0,3 @@

import { URIComponents, URIOptions } from "../uri";
declare var _default: {
scheme: string;
domainHost: boolean;
parse: (components: URIComponents, options: URIOptions) => URIComponents;
serialize: (components: URIComponents, options: URIOptions) => URIComponents;
};
export default _default;
import { URISchemeHandler } from "../uri";
declare const handler: URISchemeHandler;
export default handler;
import http from "./http";
export default {
const handler = {
scheme: "https",

@@ -8,2 +8,3 @@ domainHost: http.domainHost,

};
export default handler;
//# sourceMappingURL=https.js.map

@@ -1,2 +0,2 @@

import { URIComponents, URIOptions } from "../uri";
import { URISchemeHandler, URIComponents } from "../uri";
export interface MailtoHeaders {

@@ -11,7 +11,3 @@ [hfname: string]: string;

}
declare var _default: {
scheme: string;
parse: (components: MailtoComponents, options: URIOptions) => MailtoComponents;
serialize: (components: MailtoComponents, options: URIOptions) => URIComponents;
};
export default _default;
declare const handler: URISchemeHandler<MailtoComponents>;
export default handler;

@@ -54,11 +54,12 @@ import { pctEncChar, pctDecChars, unescapeComponent } from "../uri";

}
export default {
const handler = {
scheme: "mailto",
parse: function (components, options) {
const to = components.to = (components.path ? components.path.split(",") : []);
components.path = undefined;
if (components.query) {
const mailtoComponents = components;
const to = mailtoComponents.to = (mailtoComponents.path ? mailtoComponents.path.split(",") : []);
mailtoComponents.path = undefined;
if (mailtoComponents.query) {
let unknownHeaders = false;
const headers = {};
const hfields = components.query.split("&");
const hfields = mailtoComponents.query.split("&");
for (let x = 0, xl = hfields.length; x < xl; ++x) {

@@ -74,6 +75,6 @@ const hfield = hfields[x].split("=");

case "subject":
components.subject = unescapeComponent(hfield[1], options);
mailtoComponents.subject = unescapeComponent(hfield[1], options);
break;
case "body":
components.body = unescapeComponent(hfield[1], options);
mailtoComponents.body = unescapeComponent(hfield[1], options);
break;

@@ -87,5 +88,5 @@ default:

if (unknownHeaders)
components.headers = headers;
mailtoComponents.headers = headers;
}
components.query = undefined;
mailtoComponents.query = undefined;
for (let x = 0, xl = to.length; x < xl; ++x) {

@@ -100,3 +101,3 @@ const addr = to[x].split("@");

catch (e) {
components.error = components.error || "Email address's domain name can not be converted to ASCII via punycode: " + e;
mailtoComponents.error = mailtoComponents.error || "Email address's domain name can not be converted to ASCII via punycode: " + e;
}

@@ -109,6 +110,7 @@ }

}
return components;
return mailtoComponents;
},
serialize: function (components, options) {
const to = toArray(components.to);
serialize: function (mailtoComponents, options) {
const components = mailtoComponents;
const to = toArray(mailtoComponents.to);
if (to) {

@@ -131,7 +133,7 @@ for (let x = 0, xl = to.length; x < xl; ++x) {

}
const headers = components.headers = components.headers || {};
if (components.subject)
headers["subject"] = components.subject;
if (components.body)
headers["body"] = components.body;
const headers = mailtoComponents.headers = mailtoComponents.headers || {};
if (mailtoComponents.subject)
headers["subject"] = mailtoComponents.subject;
if (mailtoComponents.body)
headers["body"] = mailtoComponents.body;
const fields = [];

@@ -151,2 +153,3 @@ for (const name in headers) {

};
export default handler;
//# sourceMappingURL=mailto.js.map

@@ -1,7 +0,7 @@

import { URIComponents, URIOptions } from "../uri";
declare var _default: {
scheme: string;
parse: (components: URIComponents, options: URIOptions) => URIComponents;
serialize: (components: URIComponents, options: URIOptions) => URIComponents;
};
export default _default;
import { URISchemeHandler, URIOptions } from "../uri";
import { URNComponents } from "./urn";
export interface UUIDComponents extends URNComponents {
uuid?: string;
}
declare const handler: URISchemeHandler<UUIDComponents, URIOptions, URNComponents>;
export default handler;

@@ -1,25 +0,23 @@

import { SCHEMES } from "../uri";
const UUID = /^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/;
const UUID_PARSE = /^[0-9A-Fa-f\-]{36}/;
//RFC 4122
export default {
const handler = {
scheme: "urn:uuid",
parse: function (components, options) {
if (!options.tolerant && (!components.path || !components.path.match(UUID))) {
components.error = components.error || "UUID is not valid.";
parse: function (urnComponents, options) {
const uuidComponents = urnComponents;
uuidComponents.uuid = uuidComponents.nss;
uuidComponents.nss = undefined;
if (!options.tolerant && (!uuidComponents.uuid || !uuidComponents.uuid.match(UUID))) {
uuidComponents.error = uuidComponents.error || "UUID is not valid.";
}
return components;
return uuidComponents;
},
serialize: function (components, options) {
//ensure UUID is valid
if (!options.tolerant && (!components.path || !components.path.match(UUID))) {
//invalid UUIDs can not have this scheme
components.scheme = undefined;
}
else {
//normalize UUID
components.path = (components.path || "").toLowerCase();
}
return SCHEMES["urn"].serialize(components, options);
}
serialize: function (uuidComponents, options) {
const urnComponents = uuidComponents;
//normalize UUID
urnComponents.nss = (uuidComponents.uuid || "").toLowerCase();
return urnComponents;
},
};
export default handler;
//# sourceMappingURL=urn-uuid.js.map

@@ -1,7 +0,10 @@

import { URIComponents, URIOptions } from "../uri";
declare var _default: {
scheme: string;
parse: (components: URIComponents, options: URIOptions) => URIComponents;
serialize: (components: URIComponents, options: URIOptions) => URIComponents;
};
export default _default;
import { URISchemeHandler, URIComponents, URIOptions } from "../uri";
export interface URNComponents extends URIComponents {
nid?: string;
nss?: string;
}
export interface URNOptions extends URIOptions {
nid?: string;
}
declare const handler: URISchemeHandler<URNComponents, URNOptions>;
export default handler;

@@ -1,2 +0,2 @@

import { pctEncChar, SCHEMES } from "../uri";
import { SCHEMES } from "../uri";
const NID$ = "(?:[0-9A-Za-z][0-9A-Za-z\\-]{1,31})";

@@ -11,40 +11,40 @@ const PCT_ENCODED$ = "(?:\\%[0-9A-Fa-f]{2})";

//RFC 2141
export default {
const handler = {
scheme: "urn",
parse: function (components, options) {
const matches = components.path && components.path.match(URN_PARSE);
let urnComponents = components;
if (matches) {
const scheme = "urn:" + matches[1].toLowerCase();
let schemeHandler = SCHEMES[scheme];
//in order to serialize properly,
//every URN must have a serializer that calls the URN serializer
if (!schemeHandler) {
//create fake scheme handler
schemeHandler = SCHEMES[scheme] = {
scheme: scheme,
parse: function (components, options) {
return components;
},
serialize: SCHEMES["urn"].serialize
};
const scheme = options.scheme || urnComponents.scheme || "urn";
const nid = matches[1].toLowerCase();
const nss = matches[2];
const urnScheme = `${scheme}:${options.nid || nid}`;
const schemeHandler = SCHEMES[urnScheme];
urnComponents.nid = nid;
urnComponents.nss = nss;
urnComponents.path = undefined;
if (schemeHandler) {
urnComponents = schemeHandler.parse(urnComponents, options);
}
components.scheme = scheme;
components.path = matches[2];
components = schemeHandler.parse(components, options);
}
else {
components.error = components.error || "URN can not be parsed.";
urnComponents.error = urnComponents.error || "URN can not be parsed.";
}
return components;
return urnComponents;
},
serialize: function (components, options) {
const scheme = components.scheme || options.scheme;
if (scheme && scheme !== "urn") {
const matches = scheme.match(URN_SCHEME) || ["urn:" + scheme, scheme];
components.scheme = "urn";
components.path = matches[1] + ":" + (components.path ? components.path.replace(URN_EXCLUDED, pctEncChar) : "");
serialize: function (urnComponents, options) {
const scheme = options.scheme || urnComponents.scheme || "urn";
const nid = urnComponents.nid;
const urnScheme = `${scheme}:${options.nid || nid}`;
const schemeHandler = SCHEMES[urnScheme];
if (schemeHandler) {
urnComponents = schemeHandler.serialize(urnComponents, options);
}
return components;
}
const uriComponents = urnComponents;
const nss = urnComponents.nss;
uriComponents.path = `${nid || options.nid}:${nss}`;
return uriComponents;
},
};
export default handler;
//# sourceMappingURL=urn.js.map

@@ -21,6 +21,6 @@ export interface URIComponents {

}
export interface URISchemeHandler {
export interface URISchemeHandler<Components extends URIComponents = URIComponents, Options extends URIOptions = URIOptions, ParentComponents extends URIComponents = URIComponents> {
scheme: string;
parse(components: URIComponents, options: URIOptions): URIComponents;
serialize(components: URIComponents, options: URIOptions): URIComponents;
parse(components: ParentComponents, options: Options): Components;
serialize(components: Components, options: Options): ParentComponents;
unicodeSupport?: boolean;

@@ -42,2 +42,3 @@ domainHost?: boolean;

PCT_ENCODED: RegExp;
IPV4ADDRESS: RegExp;
IPV6ADDRESS: RegExp;

@@ -44,0 +45,0 @@ }

@@ -111,3 +111,64 @@ /**

;
const URI_PARSE = /^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[\dA-F:.]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i;
function _stripLeadingZeros(str) {
return str.replace(/^0*(.*)/, "$1") || "0";
}
function _normalizeIPv4(host, protocol) {
const matches = host.match(protocol.IPV4ADDRESS) || [];
const [, address] = matches;
if (address) {
return address.split(".").map(_stripLeadingZeros).join(".");
}
else {
return host;
}
}
function _normalizeIPv6(host, protocol) {
const matches = host.match(protocol.IPV6ADDRESS) || [];
const [, address, zone] = matches;
if (address) {
const [last, first] = address.toLowerCase().split('::').reverse();
const firstFields = first ? first.split(":").map(_stripLeadingZeros) : [];
const lastFields = last.split(":").map(_stripLeadingZeros);
const isLastFieldIPv4Address = protocol.IPV4ADDRESS.test(lastFields[lastFields.length - 1]);
const fieldCount = isLastFieldIPv4Address ? 7 : 8;
const lastFieldsStart = lastFields.length - fieldCount;
const fields = Array(fieldCount);
for (let x = 0; x < fieldCount; ++x) {
fields[x] = firstFields[x] || lastFields[lastFieldsStart + x] || '';
}
if (isLastFieldIPv4Address) {
fields[fieldCount - 1] = _normalizeIPv4(fields[fieldCount - 1], protocol);
}
const allZeroFields = fields.reduce((acc, field, index) => {
if (!field || field === "0") {
const lastLongest = acc[acc.length - 1];
if (lastLongest && lastLongest.index + lastLongest.length === index) {
lastLongest.length++;
}
else {
acc.push({ index, length: 1 });
}
}
return acc;
}, []);
const longestZeroFields = allZeroFields.sort((a, b) => b.length - a.length)[0];
let newHost;
if (longestZeroFields && longestZeroFields.length > 1) {
const newFirst = fields.slice(0, longestZeroFields.index);
const newLast = fields.slice(longestZeroFields.index + longestZeroFields.length);
newHost = newFirst.join(":") + "::" + newLast.join(":");
}
else {
newHost = fields.join(":");
}
if (zone) {
newHost += "%" + zone;
}
return newHost;
}
else {
return host;
}
}
const URI_PARSE = /^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i;
const NO_MATCH_IS_UNDEFINED = ("").match(/(){0}/)[1] === undefined;

@@ -135,3 +196,3 @@ export function parse(uriString, options = {}) {

}
else {
else { //IE FIX for improper RegExp matching
//store each component

@@ -150,5 +211,5 @@ components.scheme = matches[1] || undefined;

}
//strip brackets from IPv6 hosts
if (components.host) {
components.host = components.host.replace(protocol.IPV6ADDRESS, "$1");
//normalize IP hosts
components.host = _normalizeIPv6(_normalizeIPv4(components.host, protocol), protocol);
}

@@ -212,4 +273,4 @@ //determine reference type

if (components.host !== undefined) {
//ensure IPv6 addresses are bracketed
uriTokens.push(String(components.host).replace(protocol.IPV6ADDRESS, "[$1]"));
//normalize IP hosts, add brackets and escape zone separator for IPv6
uriTokens.push(_normalizeIPv6(_normalizeIPv4(String(components.host), protocol), protocol).replace(protocol.IPV6ADDRESS, (_, $1, $2) => "[" + $1 + ($2 ? "%25" + $2 : "") + "]"));
}

@@ -272,2 +333,3 @@ if (typeof components.port === "number") {

}
//if host component is a domain name
else if (options.domainHost || (schemeHandler && schemeHandler.domainHost)) {

@@ -274,0 +336,0 @@ //convert IDN via punycode

{
"name": "uri-js",
"version": "3.0.2",
"version": "4.2.0",
"description": "An RFC 3986/3987 compliant, scheme extendable URI/IRI parsing/validating/resolving library for JavaScript.",

@@ -28,2 +28,3 @@ "main": "dist/es5/uri.all.js",

"URN",
"UUID",
"HTTP",

@@ -40,3 +41,5 @@ "HTTPS",

"RFC4291",
"RFC6068"
"RFC5952",
"RFC6068",
"RFC6874"
],

@@ -59,3 +62,3 @@ "author": "Gary Court <gary.court@gmail.com>",

"sorcery": "^0.10.0",
"typescript": "^2.2.1",
"typescript": "^2.8.1",
"uglify-js": "^2.8.14"

@@ -62,0 +65,0 @@ },

# URI.js
URI.js is an [RFC 3986](http://www.ietf.org/rfc/rfc3986.txt) compliant, scheme extendable URI parsing/validating/resolving library for all JavaScript environments (browsers, Node.js, etc).
It is also compliant with the IRI ([RFC 3987](http://www.ietf.org/rfc/rfc3987.txt)) and IDNA ([RFC 5890](http://www.ietf.org/rfc/rfc5890.txt)) specifications.
It is also compliant with the IRI ([RFC 3987](http://www.ietf.org/rfc/rfc3987.txt)), IDNA ([RFC 5890](http://www.ietf.org/rfc/rfc5890.txt)), IPv6 Address ([RFC 5952](http://www.ietf.org/rfc/rfc5952.txt)), IPv6 Zone Identifier ([RFC 6874](http://www.ietf.org/rfc/rfc6874.txt)) specifications.
URI.js has an extensive test suite, and works in all (Node.js, web) environments. It weighs in at 5.6kb (gzipped, 15kb deflated).
URI.js has an extensive test suite, and works in all (Node.js, web) environments. It weighs in at 6.2kb (gzipped, 16kb deflated).
## API
### Parsing & Validating
### Parsing
var components = URI.parse("uri://user:pass@example.com:123/one/two.three?q1=a1&q2=a2#body");
URI.parse("uri://user:pass@example.com:123/one/two.three?q1=a1&q2=a2#body");
//returns:

@@ -40,2 +40,17 @@ //{

### IP Support
//IPv4 normalization
URI.normalize("//192.068.001.000") === "//192.68.1.0"
//IPv6 normalization
URI.normalize("//[2001:0:0DB8::0:0001]") === "//[2001:0:db8::1]"
//IPv6 zone identifier support
URI.parse("//[2001:db8::7%25en1]");
//returns:
//{
// host : "2001:db8::7%en1"
//}
### IRI Support

@@ -115,2 +130,22 @@

### URN Support
URI.parse("urn:example:foo");
//returns:
//{
// scheme : "urn",
// nid : "example",
// nss : "foo",
//}
#### URN UUID Support
URI.parse("urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6");
//returns:
//{
// scheme : "urn",
// nid : "example",
// uuid : "f81d4fae-7dec-11d0-a765-00a0c91e6bf6",
//}
## Usage

@@ -128,3 +163,3 @@

var URI = require("uri-js");
const URI = require("uri-js");

@@ -139,7 +174,15 @@ If you are writing your code in ES6+ (ESNEXT) or TypeScript, you would load it using:

## Breaking changes from 2.x
## Breaking changes
### Breaking changes from 3.x
URN parsing has been completely changed to better align with the specification. Scheme is now always `urn`, but has two new properties: `nid` which contains the Namspace Identifier, and `nss` which contains the Namespace Specific String. The `nss` property will be removed by higher order scheme handlers, such as the UUID URN scheme handler.
The UUID of a URN can now be found in the `uuid` property.
### Breaking changes from 2.x
URI validation has been removed as it was slow, exposed a vulnerabilty, and was generally not useful.
## Breaking changes from 1.x
### Breaking changes from 1.x

@@ -146,0 +189,0 @@ The `errors` array on parsed components is now an `error` string.

import { SCHEMES } from "./uri";
import http from "./schemes/http";
SCHEMES["http"] = http;
SCHEMES[http.scheme] = http;
import https from "./schemes/https";
SCHEMES["https"] = https;
SCHEMES[https.scheme] = https;
import mailto from "./schemes/mailto";
SCHEMES["mailto"] = mailto;
SCHEMES[mailto.scheme] = mailto;
import urn from "./schemes/urn";
SCHEMES["urn"] = urn;
SCHEMES[urn.scheme] = urn;
import uuid from "./schemes/urn-uuid";
SCHEMES["urn:uuid"] = uuid;
SCHEMES[uuid.scheme] = uuid;
export * from "./uri";

@@ -9,13 +9,17 @@ declare module 'punycode' {

export default {
'version': '2.2.0',
interface Punycode {
'version': '2.2.0';
'ucs2': {
'decode': ucs2decode,
'encode': ucs2encode
'decode': typeof ucs2decode;
'encode': typeof ucs2encode;
},
'decode': decode,
'encode': encode,
'toASCII': toASCII,
'toUnicode': toUnicode
};
'decode': typeof decode;
'encode': typeof encode;
'toASCII': typeof toASCII;
'toUnicode': typeof toUnicode;
}
const punycode:Punycode;
export default punycode;
}

@@ -23,3 +23,4 @@ import { URIRegExps } from "./uri";

DEC_OCTET$ = subexp(subexp("25[0-5]") + "|" + subexp("2[0-4]" + DIGIT$$) + "|" + subexp("1" + DIGIT$$ + DIGIT$$) + "|" + subexp("[1-9]" + DIGIT$$) + "|" + DIGIT$$),
IPV4ADDRESS$ = subexp(DEC_OCTET$ + "\\." + DEC_OCTET$ + "\\." + DEC_OCTET$ + "\\." + DEC_OCTET$),
DEC_OCTET_RELAXED$ = subexp(subexp("25[0-5]") + "|" + subexp("2[0-4]" + DIGIT$$) + "|" + subexp("1" + DIGIT$$ + DIGIT$$) + "|" + subexp("0?[1-9]" + DIGIT$$) + "|0?0?" + DIGIT$$), //relaxed parsing rules
IPV4ADDRESS$ = subexp(DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$),
H16$ = subexp(HEXDIG$$ + "{1,4}"),

@@ -37,4 +38,7 @@ LS32$ = subexp(subexp(H16$ + "\\:" + H16$) + "|" + IPV4ADDRESS$),

IPV6ADDRESS$ = subexp([IPV6ADDRESS1$, IPV6ADDRESS2$, IPV6ADDRESS3$, IPV6ADDRESS4$, IPV6ADDRESS5$, IPV6ADDRESS6$, IPV6ADDRESS7$, IPV6ADDRESS8$, IPV6ADDRESS9$].join("|")),
ZONEID$ = subexp(subexp(UNRESERVED$$ + "|" + PCT_ENCODED$) + "+"), //RFC 6874
IPV6ADDRZ$ = subexp(IPV6ADDRESS$ + "\\%25" + ZONEID$), //RFC 6874
IPV6ADDRZ_RELAXED$ = subexp(IPV6ADDRESS$ + subexp("\\%25|\\%(?!" + HEXDIG$$ + "{2})") + ZONEID$), //RFC 6874, with relaxed parsing rules
IPVFUTURE$ = subexp("[vV]" + HEXDIG$$ + "+\\." + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:]") + "+"),
IP_LITERAL$ = subexp("\\[" + subexp(IPV6ADDRESS$ + "|" + IPVFUTURE$) + "\\]"),
IP_LITERAL$ = subexp("\\[" + subexp(IPV6ADDRZ_RELAXED$ + "|" + IPV6ADDRESS$ + "|" + IPVFUTURE$) + "\\]"), //RFC 6874
REG_NAME$ = subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$)) + "*"),

@@ -82,3 +86,4 @@ HOST$ = subexp(IP_LITERAL$ + "|" + IPV4ADDRESS$ + "(?!" + REG_NAME$ + ")" + "|" + REG_NAME$),

PCT_ENCODED : new RegExp(PCT_ENCODED$, "g"),
IPV6ADDRESS : new RegExp("\\[?(" + IPV6ADDRESS$ + ")\\]?", "g")
IPV4ADDRESS : new RegExp("^(" + IPV4ADDRESS$ + ")$"),
IPV6ADDRESS : new RegExp("^\\[?(" + IPV6ADDRESS$ + ")" + subexp(subexp("\\%25|\\%(?!" + HEXDIG$$ + "{2})") + "(" + ZONEID$ + ")") + "?\\]?$") //RFC 6874, with relaxed parsing rules
};

@@ -85,0 +90,0 @@ }

@@ -1,4 +0,4 @@

import { URIComponents, URIOptions } from "../uri";
import { URISchemeHandler, URIComponents, URIOptions } from "../uri";
export default {
const handler:URISchemeHandler = {
scheme : "http",

@@ -35,1 +35,3 @@

};
export default handler;

@@ -1,5 +0,5 @@

import { URIComponents, URIOptions } from "../uri";
import { URISchemeHandler, URIComponents, URIOptions } from "../uri";
import http from "./http";
export default {
const handler:URISchemeHandler = {
scheme : "https",

@@ -10,1 +10,3 @@ domainHost : http.domainHost,

}
export default handler;

@@ -1,2 +0,2 @@

import { URIComponents, URIOptions } from "../uri";
import { URISchemeHandler, URIComponents, URIOptions } from "../uri";
import { pctEncChar, pctDecChars, unescapeComponent } from "../uri";

@@ -73,13 +73,14 @@ import punycode from "punycode";

export default {
const handler:URISchemeHandler<MailtoComponents> = {
scheme : "mailto",
parse : function (components:MailtoComponents, options:URIOptions):MailtoComponents {
const to = components.to = (components.path ? components.path.split(",") : []);
components.path = undefined;
parse : function (components:URIComponents, options:URIOptions):MailtoComponents {
const mailtoComponents = components as MailtoComponents;
const to = mailtoComponents.to = (mailtoComponents.path ? mailtoComponents.path.split(",") : []);
mailtoComponents.path = undefined;
if (components.query) {
if (mailtoComponents.query) {
let unknownHeaders = false
const headers:MailtoHeaders = {};
const hfields = components.query.split("&");
const hfields = mailtoComponents.query.split("&");

@@ -97,6 +98,6 @@ for (let x = 0, xl = hfields.length; x < xl; ++x) {

case "subject":
components.subject = unescapeComponent(hfield[1], options);
mailtoComponents.subject = unescapeComponent(hfield[1], options);
break;
case "body":
components.body = unescapeComponent(hfield[1], options);
mailtoComponents.body = unescapeComponent(hfield[1], options);
break;

@@ -110,6 +111,6 @@ default:

if (unknownHeaders) components.headers = headers;
if (unknownHeaders) mailtoComponents.headers = headers;
}
components.query = undefined;
mailtoComponents.query = undefined;

@@ -126,3 +127,3 @@ for (let x = 0, xl = to.length; x < xl; ++x) {

} catch (e) {
components.error = components.error || "Email address's domain name can not be converted to ASCII via punycode: " + e;
mailtoComponents.error = mailtoComponents.error || "Email address's domain name can not be converted to ASCII via punycode: " + e;
}

@@ -136,7 +137,8 @@ } else {

return components;
return mailtoComponents;
},
serialize : function (components:MailtoComponents, options:URIOptions):URIComponents {
const to = toArray(components.to);
serialize : function (mailtoComponents:MailtoComponents, options:URIOptions):URIComponents {
const components = mailtoComponents as URIComponents;
const to = toArray(mailtoComponents.to);
if (to) {

@@ -162,6 +164,6 @@ for (let x = 0, xl = to.length; x < xl; ++x) {

const headers = components.headers = components.headers || {};
const headers = mailtoComponents.headers = mailtoComponents.headers || {};
if (components.subject) headers["subject"] = components.subject;
if (components.body) headers["body"] = components.body;
if (mailtoComponents.subject) headers["subject"] = mailtoComponents.subject;
if (mailtoComponents.body) headers["body"] = mailtoComponents.body;

@@ -185,1 +187,3 @@ const fields = [];

}
export default handler;

@@ -1,29 +0,36 @@

import { URIComponents, URIOptions } from "../uri";
import { URISchemeHandler, URIComponents, URIOptions } from "../uri";
import { URNComponents } from "./urn";
import { SCHEMES } from "../uri";
export interface UUIDComponents extends URNComponents {
uuid?: string;
}
const UUID = /^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/;
const UUID_PARSE = /^[0-9A-Fa-f\-]{36}/;
//RFC 4122
export default {
const handler:URISchemeHandler<UUIDComponents, URIOptions, URNComponents> = {
scheme : "urn:uuid",
parse : function (components:URIComponents, options:URIOptions):URIComponents {
if (!options.tolerant && (!components.path || !components.path.match(UUID))) {
components.error = components.error || "UUID is not valid.";
parse : function (urnComponents:URNComponents, options:URIOptions):UUIDComponents {
const uuidComponents = urnComponents as UUIDComponents;
uuidComponents.uuid = uuidComponents.nss;
uuidComponents.nss = undefined;
if (!options.tolerant && (!uuidComponents.uuid || !uuidComponents.uuid.match(UUID))) {
uuidComponents.error = uuidComponents.error || "UUID is not valid.";
}
return components;
return uuidComponents;
},
serialize : function (components:URIComponents, options:URIOptions):URIComponents {
//ensure UUID is valid
if (!options.tolerant && (!components.path || !components.path.match(UUID))) {
//invalid UUIDs can not have this scheme
components.scheme = undefined;
} else {
//normalize UUID
components.path = (components.path || "").toLowerCase();
}
serialize : function (uuidComponents:UUIDComponents, options:URIOptions):URNComponents {
const urnComponents = uuidComponents as URNComponents;
//normalize UUID
urnComponents.nss = (uuidComponents.uuid || "").toLowerCase();
return urnComponents;
},
};
return SCHEMES["urn"].serialize(components, options);
}
};
export default handler;

@@ -1,4 +0,13 @@

import { URIComponents, URIOptions } from "../uri";
import { URISchemeHandler, URIComponents, URIOptions } from "../uri";
import { pctEncChar, SCHEMES } from "../uri";
export interface URNComponents extends URIComponents {
nid?:string;
nss?:string;
}
export interface URNOptions extends URIOptions {
nid?:string;
}
const NID$ = "(?:[0-9A-Za-z][0-9A-Za-z\\-]{1,31})";

@@ -14,47 +23,48 @@ const PCT_ENCODED$ = "(?:\\%[0-9A-Fa-f]{2})";

//RFC 2141
export default {
const handler:URISchemeHandler<URNComponents,URNOptions> = {
scheme : "urn",
parse : function (components:URIComponents, options:URIOptions):URIComponents {
parse : function (components:URIComponents, options:URNOptions):URNComponents {
const matches = components.path && components.path.match(URN_PARSE);
let urnComponents = components as URNComponents;
if (matches) {
const scheme = "urn:" + matches[1].toLowerCase();
let schemeHandler = SCHEMES[scheme];
const scheme = options.scheme || urnComponents.scheme || "urn";
const nid = matches[1].toLowerCase();
const nss = matches[2];
const urnScheme = `${scheme}:${options.nid || nid}`;
const schemeHandler = SCHEMES[urnScheme];
//in order to serialize properly,
//every URN must have a serializer that calls the URN serializer
if (!schemeHandler) {
//create fake scheme handler
schemeHandler = SCHEMES[scheme] = {
scheme : scheme,
parse : function (components:URIComponents, options:URIOptions):URIComponents {
return components;
},
serialize : SCHEMES["urn"].serialize
};
urnComponents.nid = nid;
urnComponents.nss = nss;
urnComponents.path = undefined;
if (schemeHandler) {
urnComponents = schemeHandler.parse(urnComponents, options) as URNComponents;
}
components.scheme = scheme;
components.path = matches[2];
components = schemeHandler.parse(components, options);
} else {
components.error = components.error || "URN can not be parsed.";
urnComponents.error = urnComponents.error || "URN can not be parsed.";
}
return components;
return urnComponents;
},
serialize : function (components:URIComponents, options:URIOptions):URIComponents {
const scheme = components.scheme || options.scheme;
serialize : function (urnComponents:URNComponents, options:URNOptions):URIComponents {
const scheme = options.scheme || urnComponents.scheme || "urn";
const nid = urnComponents.nid;
const urnScheme = `${scheme}:${options.nid || nid}`;
const schemeHandler = SCHEMES[urnScheme];
if (scheme && scheme !== "urn") {
const matches = scheme.match(URN_SCHEME) || ["urn:" + scheme, scheme];
components.scheme = "urn";
components.path = matches[1] + ":" + (components.path ? components.path.replace(URN_EXCLUDED, pctEncChar) : "");
if (schemeHandler) {
urnComponents = schemeHandler.serialize(urnComponents, options) as URNComponents;
}
return components;
}
const uriComponents = urnComponents as URIComponents;
const nss = urnComponents.nss;
uriComponents.path = `${nid || options.nid}:${nss}`;
return uriComponents;
},
};
export default handler;

@@ -43,30 +43,30 @@ /**

export interface URIComponents {
scheme?:string,
userinfo?:string,
host?:string,
port?:number|string,
path?:string,
query?:string,
fragment?:string,
reference?:string,
error?:string
scheme?:string;
userinfo?:string;
host?:string;
port?:number|string;
path?:string;
query?:string;
fragment?:string;
reference?:string;
error?:string;
}
export interface URIOptions {
scheme?:string,
reference?:string,
tolerant?:boolean,
absolutePath?:boolean,
iri?:boolean,
unicodeSupport?:boolean,
domainHost?:boolean
scheme?:string;
reference?:string;
tolerant?:boolean;
absolutePath?:boolean;
iri?:boolean;
unicodeSupport?:boolean;
domainHost?:boolean;
}
export interface URISchemeHandler {
scheme:string,
parse(components:URIComponents, options:URIOptions):URIComponents,
serialize(components:URIComponents, options:URIOptions):URIComponents,
unicodeSupport?:boolean,
domainHost?:boolean,
absolutePath?:boolean
export interface URISchemeHandler<Components extends URIComponents = URIComponents, Options extends URIOptions = URIOptions, ParentComponents extends URIComponents = URIComponents> {
scheme:string;
parse(components:ParentComponents, options:Options):Components;
serialize(components:Components, options:Options):ParentComponents;
unicodeSupport?:boolean;
domainHost?:boolean;
absolutePath?:boolean;
}

@@ -86,3 +86,4 @@

PCT_ENCODED : RegExp,
IPV6ADDRESS : RegExp
IPV4ADDRESS : RegExp,
IPV6ADDRESS : RegExp,
}

@@ -160,3 +161,72 @@

const URI_PARSE = /^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[\dA-F:.]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i;
function _stripLeadingZeros(str:string):string {
return str.replace(/^0*(.*)/, "$1") || "0";
}
function _normalizeIPv4(host:string, protocol:URIRegExps):string {
const matches = host.match(protocol.IPV4ADDRESS) || [];
const [, address] = matches;
if (address) {
return address.split(".").map(_stripLeadingZeros).join(".");
} else {
return host;
}
}
function _normalizeIPv6(host:string, protocol:URIRegExps):string {
const matches = host.match(protocol.IPV6ADDRESS) || [];
const [, address, zone] = matches;
if (address) {
const [last, first] = address.toLowerCase().split('::').reverse();
const firstFields = first ? first.split(":").map(_stripLeadingZeros) : [];
const lastFields = last.split(":").map(_stripLeadingZeros);
const isLastFieldIPv4Address = protocol.IPV4ADDRESS.test(lastFields[lastFields.length - 1]);
const fieldCount = isLastFieldIPv4Address ? 7 : 8;
const lastFieldsStart = lastFields.length - fieldCount;
const fields = Array<string>(fieldCount);
for (let x = 0; x < fieldCount; ++x) {
fields[x] = firstFields[x] || lastFields[lastFieldsStart + x] || '';
}
if (isLastFieldIPv4Address) {
fields[fieldCount - 1] = _normalizeIPv4(fields[fieldCount - 1], protocol);
}
const allZeroFields = fields.reduce<Array<{index:number,length:number}>>((acc, field, index) => {
if (!field || field === "0") {
const lastLongest = acc[acc.length - 1];
if (lastLongest && lastLongest.index + lastLongest.length === index) {
lastLongest.length++;
} else {
acc.push({ index, length : 1 });
}
}
return acc;
}, []);
const longestZeroFields = allZeroFields.sort((a, b) => b.length - a.length)[0];
let newHost:string;
if (longestZeroFields && longestZeroFields.length > 1) {
const newFirst = fields.slice(0, longestZeroFields.index) ;
const newLast = fields.slice(longestZeroFields.index + longestZeroFields.length);
newHost = newFirst.join(":") + "::" + newLast.join(":");
} else {
newHost = fields.join(":");
}
if (zone) {
newHost += "%" + zone;
}
return newHost;
} else {
return host;
}
}
const URI_PARSE = /^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i;
const NO_MATCH_IS_UNDEFINED = (<RegExpMatchArray>("").match(/(){0}/))[1] === undefined;

@@ -203,5 +273,5 @@

//strip brackets from IPv6 hosts
if (components.host) {
components.host = components.host.replace(protocol.IPV6ADDRESS, "$1");
//normalize IP hosts
components.host = _normalizeIPv6(_normalizeIPv4(components.host, protocol), protocol);
}

@@ -267,4 +337,4 @@

if (components.host !== undefined) {
//ensure IPv6 addresses are bracketed
uriTokens.push(String(components.host).replace(protocol.IPV6ADDRESS, "[$1]"));
//normalize IP hosts, add brackets and escape zone separator for IPv6
uriTokens.push(_normalizeIPv6(_normalizeIPv4(String(components.host), protocol), protocol).replace(protocol.IPV6ADDRESS, (_, $1, $2) => "[" + $1 + ($2 ? "%25" + $2 : "") + "]"));
}

@@ -271,0 +341,0 @@

@@ -229,2 +229,35 @@ //

strictEqual(components.fragment, undefined, "fragment");
//IPv6address, example from RFC 5952
components = URI.parse("//[2001:db8::1]:80");
strictEqual(components.error, undefined, "IPv6address errors");
strictEqual(components.scheme, undefined, "scheme");
strictEqual(components.userinfo, undefined, "userinfo");
strictEqual(components.host, "2001:db8::1", "host");
strictEqual(components.port, 80, "port");
strictEqual(components.path, "", "path");
strictEqual(components.query, undefined, "query");
strictEqual(components.fragment, undefined, "fragment");
//IPv6address with zone identifier, RFC 6874
components = URI.parse("//[fe80::a%25en1]");
strictEqual(components.error, undefined, "IPv4address errors");
strictEqual(components.scheme, undefined, "scheme");
strictEqual(components.userinfo, undefined, "userinfo");
strictEqual(components.host, "fe80::a%en1", "host");
strictEqual(components.port, undefined, "port");
strictEqual(components.path, "", "path");
strictEqual(components.query, undefined, "query");
strictEqual(components.fragment, undefined, "fragment");
//IPv6address with an unescaped interface specifier, example from pekkanikander (https://github.com/garycourt/uri-js/pull/22)
components = URI.parse("//[2001:db8::7%en0]");
strictEqual(components.error, undefined, "IPv6address interface errors");
strictEqual(components.scheme, undefined, "scheme");
strictEqual(components.userinfo, undefined, "userinfo");
strictEqual(components.host, "2001:db8::7%en0", "host");
strictEqual(components.port, undefined, "port");
strictEqual(components.path, "", "path");
strictEqual(components.query, undefined, "query");
strictEqual(components.fragment, undefined, "fragment");
});

@@ -269,2 +302,14 @@

strictEqual(URI.serialize({path:"?query"}), "%3Fquery", "Query path");
//mixed IPv4address & reg-name, example from terion-name (https://github.com/garycourt/uri-js/issues/4)
strictEqual(URI.serialize({host:"10.10.10.10.example.com"}), "//10.10.10.10.example.com", "Mixed IPv4address & reg-name");
//IPv6address
strictEqual(URI.serialize({host:"2001:db8::7"}), "//[2001:db8::7]", "IPv6 Host");
strictEqual(URI.serialize({host:"::ffff:129.144.52.38"}), "//[::ffff:129.144.52.38]", "IPv6 Mixed Host");
strictEqual(URI.serialize({host:"2606:2800:220:1:248:1893:25c8:1946"}), "//[2606:2800:220:1:248:1893:25c8:1946]", "IPv6 Full Host");
//IPv6address with zone identifier, RFC 6874
strictEqual(URI.serialize({host:"fe80::a%en1"}), "//[fe80::a%25en1]", "IPv6 Zone Unescaped Host");
strictEqual(URI.serialize({host:"fe80::a%25en1"}), "//[fe80::a%25en1]", "IPv6 Zone Escaped Host");
});

@@ -335,4 +380,21 @@

//IPv4address
strictEqual(URI.normalize("//192.068.001.000"), "//192.68.1.0");
//IPv6address, example from RFC 3513
strictEqual(URI.normalize("http://[1080::8:800:200C:417A]/"), "http://[1080::8:800:200c:417a]/");
//IPv6address, examples from RFC 5952
strictEqual(URI.normalize("//[2001:0db8::0001]/"), "//[2001:db8::1]/");
strictEqual(URI.normalize("//[2001:db8::1:0000:1]/"), "//[2001:db8::1:0:1]/");
strictEqual(URI.normalize("//[2001:db8:0:0:0:0:2:1]/"), "//[2001:db8::2:1]/");
strictEqual(URI.normalize("//[2001:db8:0:1:1:1:1:1]/"), "//[2001:db8:0:1:1:1:1:1]/");
strictEqual(URI.normalize("//[2001:0:0:1:0:0:0:1]/"), "//[2001:0:0:1::1]/");
strictEqual(URI.normalize("//[2001:db8:0:0:1:0:0:1]/"), "//[2001:db8::1:0:0:1]/");
strictEqual(URI.normalize("//[2001:DB8::1]/"), "//[2001:db8::1]/");
strictEqual(URI.normalize("//[0:0:0:0:0:ffff:192.0.2.1]/"), "//[::ffff:192.0.2.1]/");
//Mixed IPv4 and IPv6 address
strictEqual(URI.normalize("//[1:2:3:4:5:6:192.0.2.1]/"), "//[1:2:3:4:5:6:192.0.2.1]/");
strictEqual(URI.normalize("//[1:2:3:4:5:6:192.068.001.000]/"), "//[1:2:3:4:5:6:192.68.1.0]/");
});

@@ -480,3 +542,3 @@

strictEqual(components.error, undefined, "errors");
strictEqual(components.scheme, "urn:foo", "scheme");
strictEqual(components.scheme, "urn", "scheme");
//strictEqual(components.authority, undefined, "authority");

@@ -486,5 +548,7 @@ strictEqual(components.userinfo, undefined, "userinfo");

strictEqual(components.port, undefined, "port");
strictEqual(components.path, "a123,456", "path");
strictEqual(components.path, undefined, "path");
strictEqual(components.query, undefined, "query");
strictEqual(components.fragment, undefined, "fragment");
strictEqual(components.nid, "foo", "nid");
strictEqual(components.nss, "a123,456", "nss");
});

@@ -495,4 +559,5 @@

var components = {
scheme : "urn:foo",
path : "a123,456"
scheme : "urn",
nid : "foo",
nss : "a123,456"
};

@@ -519,4 +584,13 @@ strictEqual(URI.serialize(components), "urn:foo:a123,456");

strictEqual(components.error, undefined, "errors");
strictEqual(components.scheme, "urn:uuid", "scheme");
strictEqual(components.path, "f81d4fae-7dec-11d0-a765-00a0c91e6bf6", "path");
strictEqual(components.scheme, "urn", "scheme");
//strictEqual(components.authority, undefined, "authority");
strictEqual(components.userinfo, undefined, "userinfo");
strictEqual(components.host, undefined, "host");
strictEqual(components.port, undefined, "port");
strictEqual(components.path, undefined, "path");
strictEqual(components.query, undefined, "query");
strictEqual(components.fragment, undefined, "fragment");
strictEqual(components.nid, "uuid", "nid");
strictEqual(components.nss, undefined, "nss");
strictEqual(components.uuid, "f81d4fae-7dec-11d0-a765-00a0c91e6bf6", "uuid");

@@ -530,4 +604,5 @@ components = URI.parse("urn:uuid:notauuid-7dec-11d0-a765-00a0c91e6bf6");

var components = {
scheme : "urn:uuid",
path : "f81d4fae-7dec-11d0-a765-00a0c91e6bf6"
scheme : "urn",
nid : "uuid",
uuid : "f81d4fae-7dec-11d0-a765-00a0c91e6bf6"
};

@@ -537,6 +612,7 @@ strictEqual(URI.serialize(components), "urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6");

components = {
scheme : "urn:uuid",
path : "notauuid-7dec-11d0-a765-00a0c91e6bf6"
scheme : "urn",
nid : "uuid",
uuid : "notauuid-7dec-11d0-a765-00a0c91e6bf6"
};
strictEqual(URI.serialize(components), "notauuid-7dec-11d0-a765-00a0c91e6bf6");
strictEqual(URI.serialize(components), "urn:uuid:notauuid-7dec-11d0-a765-00a0c91e6bf6");
});

@@ -548,2 +624,18 @@

test("URN NID Override", function () {
var components = URI.parse("urn:foo:f81d4fae-7dec-11d0-a765-00a0c91e6bf6", {nid:"uuid"});
strictEqual(components.error, undefined, "errors");
strictEqual(components.scheme, "urn", "scheme");
strictEqual(components.path, undefined, "path");
strictEqual(components.nid, "foo", "nid");
strictEqual(components.nss, undefined, "nss");
strictEqual(components.uuid, "f81d4fae-7dec-11d0-a765-00a0c91e6bf6", "uuid");
var components = {
scheme : "urn",
nid : "foo",
uuid : "f81d4fae-7dec-11d0-a765-00a0c91e6bf6"
};
strictEqual(URI.serialize(components, {nid:"uuid"}), "urn:foo:f81d4fae-7dec-11d0-a765-00a0c91e6bf6");
});
}

@@ -550,0 +642,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc