From 324c9eacd5fae0672085e8069bf860968d0730e8 Mon Sep 17 00:00:00 2001 From: Rodney Rehm Date: Sat, 16 Mar 2013 18:35:57 +0100 Subject: [PATCH] version bump to 1.10.0 --- README.md | 5 ++ URI.jquery.json | 2 +- build.js | 2 +- component.json | 2 +- package.json | 2 +- src/IPv6.js | 2 +- src/SecondLevelDomains.js | 2 +- src/URI.js | 2 +- src/URI.min.js | 121 +++++++++++++++++++------------------- src/URITemplate.js | 2 +- src/jquery.URI.js | 2 +- src/jquery.URI.min.js | 12 ++-- 12 files changed, 81 insertions(+), 75 deletions(-) diff --git a/README.md b/README.md index 74888372..957e4ac6 100644 --- a/README.md +++ b/README.md @@ -207,6 +207,11 @@ URI.js is published under the [MIT license](http://www.opensource.org/licenses/m ## Changelog ## +### 1.10.0 (March 16th 2013) ### + +* adding [`hasQuery()`](http://medialize.github.com/URI.js/docs.html#search-has) - ([Issue #71](https://github.com/medialize/URI.js/issues/71)) +* fixing URI property detection to return 'src' if none was detected (`jquery.URI.js`) - ([Issue #69](https://github.com/medialize/URI.js/issues/69)) + ### 1.9.1 (February 12th 2013) ### * fixing IE9 compatibility with location import: `URI(location)` diff --git a/URI.jquery.json b/URI.jquery.json index 70654e62..1fcfd62c 100644 --- a/URI.jquery.json +++ b/URI.jquery.json @@ -18,7 +18,7 @@ "URI-manipulation", "URL-manipulation" ], - "version": "1.9.1", + "version": "1.10.0", "author": { "name": "Rodney Rehm", "url": "http://rodneyrehm.de/en/" diff --git a/build.js b/build.js index 16e753b5..cf5e5c96 100644 --- a/build.js +++ b/build.js @@ -29,7 +29,7 @@ function build(files) { output_format: "text", output_info: "compiled_code" }, function(data) { - var code = "/*! URI.js v1.9.1 http://medialize.github.com/URI.js/ */\n/* build contains: " + files.join(', ') + " */\n" + data; + var code = "/*! URI.js v1.10.0 http://medialize.github.com/URI.js/ */\n/* build contains: " + files.join(', ') + " */\n" + data; $progress.hide(); $out.val(code).parent().show(); $out.prev().find('a').remove(); diff --git a/component.json b/component.json index f5b3e1ae..49fe7c9e 100644 --- a/component.json +++ b/component.json @@ -1,6 +1,6 @@ { "name": "URIjs", - "version": "1.9.1", + "version": "1.10.0", "main": [ "src/URI.js", "src/IPv6.js", diff --git a/package.json b/package.json index 92eabc40..9b4fda32 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "URIjs", - "version": "1.9.1", + "version": "1.10.0", "title": "URI.js - Mutating URLs", "author": { "name": "Rodney Rehm", diff --git a/src/IPv6.js b/src/IPv6.js index 9ca45c34..2500e76a 100644 --- a/src/IPv6.js +++ b/src/IPv6.js @@ -2,7 +2,7 @@ * URI.js - Mutating URLs * IPv6 Support * - * Version: 1.9.1 + * Version: 1.10.0 * * Author: Rodney Rehm * Web: http://medialize.github.com/URI.js/ diff --git a/src/SecondLevelDomains.js b/src/SecondLevelDomains.js index 03977e6f..ff28d857 100644 --- a/src/SecondLevelDomains.js +++ b/src/SecondLevelDomains.js @@ -2,7 +2,7 @@ * URI.js - Mutating URLs * Second Level Domain (SLD) Support * - * Version: 1.9.1 + * Version: 1.10.0 * * Author: Rodney Rehm * Web: http://medialize.github.com/URI.js/ diff --git a/src/URI.js b/src/URI.js index 59652caf..87cb97dd 100644 --- a/src/URI.js +++ b/src/URI.js @@ -1,7 +1,7 @@ /*! * URI.js - Mutating URLs * - * Version: 1.9.1 + * Version: 1.10.0 * * Author: Rodney Rehm * Web: http://medialize.github.com/URI.js/ diff --git a/src/URI.min.js b/src/URI.min.js index e51d2acf..af33b9fd 100644 --- a/src/URI.min.js +++ b/src/URI.min.js @@ -1,12 +1,12 @@ -/*! URI.js v1.9.1 http://medialize.github.com/URI.js/ */ +/*! URI.js v1.10.0 http://medialize.github.com/URI.js/ */ /* build contains: IPv6.js, punycode.js, SecondLevelDomains.js, URI.js, URITemplate.js */ -(function(f,g){"object"===typeof exports?module.exports=g():"function"===typeof define&&define.amd?define(g):f.IPv6=g()})(this,function(){return{best:function(f){f=f.toLowerCase().split(":");var g=f.length,j=8;""===f[0]&&""===f[1]&&""===f[2]?(f.shift(),f.shift()):""===f[0]&&""===f[1]?f.shift():""===f[g-1]&&""===f[g-2]&&f.pop();g=f.length;-1!==f[g-1].indexOf(".")&&(j=7);var d;for(d=0;dm;m++)if("0"===g[0]&&1m&&(g=h,m=u)):"0"==f[d]&&(c=!0,h=d,u=1);u>m&&(g=h,m=u);1>>10&1023|55296),a=56320|a&1023);return b+=A(a)}).join("")}function u(e,d,s){var c=0;e=s?x(e/b):e>>1;for(e+=x(e/d);e> -y*t>>1;c+=l)e=x(e/y);return x(c+(y+1)*e/(e+a))}function h(a){var b=[],d=a.length,c,h=0,f=s,w=e,n,j,p,k,r;n=a.lastIndexOf(C);0>n&&(n=0);for(j=0;j=d&&g("invalid-input");k=a.charCodeAt(n++);k=10>k-48?k-22:26>k-65?k-65:26>k-97?k-97:l;(k>=l||k>x((q-h)/c))&&g("overflow");h+=k*c;r=p<=w?v:p>=w+t?t:p-w;if(kx(q/k)&&g("overflow");c*=k}c=b.length+1;w=u(h-j,c,0==j);x(h/c)>q-f&&g("overflow"); -f+=x(h/c);h%=c;b.splice(h++,0,f)}return m(b)}function c(a){var b,c,h,f,w,n,k,j,p,r=[],m,z,y;a=d(a);m=a.length;b=s;c=0;w=e;for(n=0;np&&r.push(A(p));for((h=f=r.length)&&r.push(C);h=b&&px((q-c)/z)&&g("overflow");c+=(k-b)*z;b=k;for(n=0;nq&&g("overflow"),p==b){j=c;for(k=l;;k+=l){p=k<=w?v:k>=w+t?t:k-w;if(jp+y%j)-0));j=x(y/j)}r.push(A(j+22+75*(26>j)-0));w=u(c,z, -h==f);c=0;++h}++c;++b}return r.join("")}var n,p="function"==typeof define&&"object"==typeof define.amd&&define.amd&&define,k="object"==typeof exports&&exports,r="object"==typeof module&&module,q=2147483647,l=36,v=1,t=26,a=38,b=700,e=72,s=128,C="-",w=/[^ -~]/,z=/^xn--/,D={overflow:"Overflow: input needs wider integers to process.","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},y=l-v,x=Math.floor,A=String.fromCharCode,B;n={version:"1.1.1",ucs2:{decode:d, -encode:m},decode:h,encode:c,toASCII:function(a){return j(a.split("."),function(a){return w.test(a)?"xn--"+c(a):a}).join(".")},toUnicode:function(a){return j(a.split("."),function(a){return z.test(a)?h(a.slice(4).toLowerCase()):a}).join(".")}};if(k)if(r&&r.exports==k)r.exports=n;else for(B in n)n.hasOwnProperty(B)&&(k[B]=n[B]);else p?define("punycode",n):f.punycode=n})(this); +(function(f,g){"object"===typeof exports?module.exports=g():"function"===typeof define&&define.amd?define(g):f.IPv6=g()})(this,function(){return{best:function(f){f=f.toLowerCase().split(":");var g=f.length,j=8;""===f[0]&&""===f[1]&&""===f[2]?(f.shift(),f.shift()):""===f[0]&&""===f[1]?f.shift():""===f[g-1]&&""===f[g-2]&&f.pop();g=f.length;-1!==f[g-1].indexOf(".")&&(j=7);var c;for(c=0;cr;r++)if("0"===g[0]&&1r&&(g=s,r=t)):"0"==f[c]&&(h=!0,s=c,t=1);t>r&&(g=s,r=t);1>>10&1023|55296),a=56320|a&1023);return b+=C(a)}).join("")}function t(a,b,d){var c=0;a=d?z(a/B):a>>1;for(a+=z(a/b);a> +v*x>>1;c+=l)a=z(a/v);return z(c+(v+1)*a/(a+u))}function s(d){var c=[],k=d.length,m,e=0,s=a,f=A,h,v,j,p,q;h=d.lastIndexOf(b);0>h&&(h=0);for(v=0;v=k&&g("invalid-input");p=d.charCodeAt(h++);p=10>p-48?p-22:26>p-65?p-65:26>p-97?p-97:l;(p>=l||p>z((n-e)/m))&&g("overflow");e+=p*m;q=j<=f?w:j>=f+x?x:j-f;if(pz(n/p)&&g("overflow");m*=p}m=c.length+1;f=t(e-v,m,0==v);z(e/m)>n-s&&g("overflow"); +s+=z(e/m);e%=m;c.splice(e++,0,s)}return r(c)}function h(d){var k,m,e,s,f,h,v,p,j,q=[],y,r,u;d=c(d);y=d.length;k=a;m=0;f=A;for(h=0;hj&&q.push(C(j));for((e=s=q.length)&&q.push(b);e=k&&jz((n-m)/r)&&g("overflow");m+=(v-k)*r;k=v;for(h=0;hn&&g("overflow"),j==k){p=m;for(v=l;;v+=l){j=v<=f?w:v>=f+x?x:v-f;if(pj+u%p)-0));p=z(u/p)}q.push(C(p+22+75*(26>p)-0));f=t(m,r, +e==s);m=0;++e}++m;++k}return q.join("")}var p,y="function"==typeof define&&"object"==typeof define.amd&&define.amd&&define,e="object"==typeof exports&&exports,q="object"==typeof module&&module,n=2147483647,l=36,w=1,x=26,u=38,B=700,A=72,a=128,b="-",d=/[^ -~]/,k=/^xn--/,m={overflow:"Overflow: input needs wider integers to process.","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},v=l-w,z=Math.floor,C=String.fromCharCode,D;p={version:"1.1.1",ucs2:{decode:c, +encode:r},decode:s,encode:h,toASCII:function(a){return j(a.split("."),function(a){return d.test(a)?"xn--"+h(a):a}).join(".")},toUnicode:function(a){return j(a.split("."),function(a){return k.test(a)?s(a.slice(4).toLowerCase()):a}).join(".")}};if(e)if(q&&q.exports==e)q.exports=p;else for(D in p)p.hasOwnProperty(D)&&(e[D]=p[D]);else y?define("punycode",p):f.punycode=p})(this); (function(f,g){"object"===typeof exports?module.exports=g():"function"===typeof define&&define.amd?define(g):f.SecondLevelDomains=g()})(this,function(){var f=Object.prototype.hasOwnProperty,g={list:{ac:"com|gov|mil|net|org",ae:"ac|co|gov|mil|name|net|org|pro|sch",af:"com|edu|gov|net|org",al:"com|edu|gov|mil|net|org",ao:"co|ed|gv|it|og|pb",ar:"com|edu|gob|gov|int|mil|net|org|tur",at:"ac|co|gv|or",au:"asn|com|csiro|edu|gov|id|net|org",ba:"co|com|edu|gov|mil|net|org|rs|unbi|unmo|unsa|untz|unze",bb:"biz|co|com|edu|gov|info|net|org|store|tv", bh:"biz|cc|com|edu|gov|info|net|org",bn:"com|edu|gov|net|org",bo:"com|edu|gob|gov|int|mil|net|org|tv",br:"adm|adv|agr|am|arq|art|ato|b|bio|blog|bmd|cim|cng|cnt|com|coop|ecn|edu|eng|esp|etc|eti|far|flog|fm|fnd|fot|fst|g12|ggf|gov|imb|ind|inf|jor|jus|lel|mat|med|mil|mus|net|nom|not|ntr|odo|org|ppg|pro|psc|psi|qsl|rec|slg|srv|tmp|trd|tur|tv|vet|vlog|wiki|zlg",bs:"com|edu|gov|net|org",bz:"du|et|om|ov|rg",ca:"ab|bc|mb|nb|nf|nl|ns|nt|nu|on|pe|qc|sk|yk",ck:"biz|co|edu|gen|gov|info|net|org",cn:"ac|ah|bj|com|cq|edu|fj|gd|gov|gs|gx|gz|ha|hb|he|hi|hl|hn|jl|js|jx|ln|mil|net|nm|nx|org|qh|sc|sd|sh|sn|sx|tj|tw|xj|xz|yn|zj", co:"com|edu|gov|mil|net|nom|org",cr:"ac|c|co|ed|fi|go|or|sa",cy:"ac|biz|com|ekloges|gov|ltd|name|net|org|parliament|press|pro|tm","do":"art|com|edu|gob|gov|mil|net|org|sld|web",dz:"art|asso|com|edu|gov|net|org|pol",ec:"com|edu|fin|gov|info|med|mil|net|org|pro",eg:"com|edu|eun|gov|mil|name|net|org|sci",er:"com|edu|gov|ind|mil|net|org|rochest|w",es:"com|edu|gob|nom|org",et:"biz|com|edu|gov|info|name|net|org",fj:"ac|biz|com|info|mil|name|net|org|pro",fk:"ac|co|gov|net|nom|org",fr:"asso|com|f|gouv|nom|prd|presse|tm", @@ -19,56 +19,57 @@ tw:"club|com|ebiz|edu|game|gov|idv|mil|net|org",mu:"ac|co|com|gov|net|or|org",mz rw:"ac|co|com|edu|gouv|gov|int|mil|net",sa:"com|edu|gov|med|net|org|pub|sch",sd:"com|edu|gov|info|med|net|org|tv",se:"a|ac|b|bd|c|d|e|f|g|h|i|k|l|m|n|o|org|p|parti|pp|press|r|s|t|tm|u|w|x|y|z",sg:"com|edu|gov|idn|net|org|per",sn:"art|com|edu|gouv|org|perso|univ",sy:"com|edu|gov|mil|net|news|org",th:"ac|co|go|in|mi|net|or",tj:"ac|biz|co|com|edu|go|gov|info|int|mil|name|net|nic|org|test|web",tn:"agrinet|com|defense|edunet|ens|fin|gov|ind|info|intl|mincom|nat|net|org|perso|rnrt|rns|rnu|tourism",tz:"ac|co|go|ne|or", ua:"biz|cherkassy|chernigov|chernovtsy|ck|cn|co|com|crimea|cv|dn|dnepropetrovsk|donetsk|dp|edu|gov|if|in|ivano-frankivsk|kh|kharkov|kherson|khmelnitskiy|kiev|kirovograd|km|kr|ks|kv|lg|lugansk|lutsk|lviv|me|mk|net|nikolaev|od|odessa|org|pl|poltava|pp|rovno|rv|sebastopol|sumy|te|ternopil|uzhgorod|vinnica|vn|zaporizhzhe|zhitomir|zp|zt",ug:"ac|co|go|ne|or|org|sc",uk:"ac|bl|british-library|co|cym|gov|govt|icnet|jet|lea|ltd|me|mil|mod|national-library-scotland|nel|net|nhs|nic|nls|org|orgn|parliament|plc|police|sch|scot|soc", us:"dni|fed|isa|kids|nsn",uy:"com|edu|gub|mil|net|org",ve:"co|com|edu|gob|info|mil|net|org|web",vi:"co|com|k12|net|org",vn:"ac|biz|com|edu|gov|health|info|int|name|net|org|pro",ye:"co|com|gov|ltd|me|net|org|plc",yu:"ac|co|edu|gov|org",za:"ac|agric|alt|bourse|city|co|cybernet|db|edu|gov|grondar|iaccess|imt|inca|landesign|law|mil|net|ngo|nis|nom|olivetti|org|pix|school|tm|web",zm:"ac|co|com|edu|gov|net|org|sch"},has_expression:null,is_expression:null,has:function(f){return!!f.match(g.has_expression)}, -is:function(f){return!!f.match(g.is_expression)},get:function(f){return(f=f.match(g.has_expression))&&f[1]||null},init:function(){var j="",d;for(d in g.list)f.call(g.list,d)&&(j+="|("+("("+g.list[d]+")."+d)+")");g.has_expression=RegExp("\\.("+j.substr(1)+")$","i");g.is_expression=RegExp("^("+j.substr(1)+")$","i")}};g.init();return g}); -(function(f,g){"object"===typeof exports?module.exports=g(require("./punycode"),require("./IPv6"),require("./SecondLevelDomains")):"function"===typeof define&&define.amd?define(["./punycode","./IPv6","./SecondLevelDomains"],g):f.URI=g(f.punycode,f.IPv6,f.SecondLevelDomains)})(this,function(f,g,j){function d(a,b){if(!(this instanceof d))return new d(a,b);void 0===a&&(a="undefined"!==typeof location?location.href+"":"");this.href(a);return void 0!==b?this.absoluteTo(b):this}function m(a){return a.replace(/([.*+?^=!:${}()|[\]\/\\])/g, -"\\$1")}function u(a){return"[object Array]"===String(Object.prototype.toString.call(a))}function h(a){return encodeURIComponent(a).replace(/[!'()*]/g,escape).replace(/\*/g,"%2A")}var c=d.prototype,n=Object.prototype.hasOwnProperty;d._parts=function(){return{protocol:null,username:null,password:null,hostname:null,urn:null,port:null,path:null,query:null,fragment:null,duplicateQueryParameters:d.duplicateQueryParameters}};d.duplicateQueryParameters=!1;d.protocol_expression=/^[a-z][a-z0-9-+-]*$/i;d.idn_expression= -/[^a-z0-9\.-]/i;d.punycode_expression=/(xn--)/i;d.ip4_expression=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;d.ip6_expression=/^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/; -d.find_uri_expression=/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?\u00ab\u00bb\u201c\u201d\u2018\u2019]))/ig;d.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"};d.invalid_hostname_characters=/[^a-zA-Z0-9\.-]/;d.encode=h;d.decode=decodeURIComponent;d.iso8859=function(){d.encode=escape;d.decode=unescape};d.unicode=function(){d.encode= -h;d.decode=decodeURIComponent};d.characters={pathname:{encode:{expression:/%(24|26|2B|2C|3B|3D|3A|40)/ig,map:{"%24":"$","%26":"&","%2B":"+","%2C":",","%3B":";","%3D":"=","%3A":":","%40":"@"}},decode:{expression:/[\/\?#]/g,map:{"/":"%2F","?":"%3F","#":"%23"}}},reserved:{encode:{expression:/%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/ig,map:{"%3A":":","%2F":"/","%3F":"?","%23":"#","%5B":"[","%5D":"]","%40":"@","%21":"!","%24":"$","%26":"&","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+", -"%2C":",","%3B":";","%3D":"="}}}};d.encodeQuery=function(a){return d.encode(a+"").replace(/%20/g,"+")};d.decodeQuery=function(a){return d.decode((a+"").replace(/\+/g,"%20"))};d.recodePath=function(a){a=(a+"").split("/");for(var b=0,e=a.length;bd)return a.charAt(0)===b.charAt(0)&&"/"===a.charAt(0)?"/":"";"/"!==a.charAt(d)&&(d=a.substring(0,d).lastIndexOf("/"));return a.substring(0, -d+1)};d.withinString=function(a,b){return a.replace(d.find_uri_expression,b)};d.ensureValidHostname=function(a){if(a.match(d.invalid_hostname_characters)){if(!f)throw new TypeError("Hostname '"+a+"' contains characters other than [A-Z0-9.-] and Punycode.js is not available");if(f.toASCII(a).match(d.invalid_hostname_characters))throw new TypeError("Hostname '"+a+"' contains characters other than [A-Z0-9.-]");}};c.build=function(a){if(!0===a)this._deferred_build=!0;else if(void 0===a||this._deferred_build)this._string= -d.build(this._parts),this._deferred_build=!1;return this};c.clone=function(){return new d(this)};c.valueOf=c.toString=function(){return this.build(!1)._string};p={protocol:"protocol",username:"username",password:"password",hostname:"hostname",port:"port"};r=function(a){return function(b,e){if(void 0===b)return this._parts[a]||"";this._parts[a]=b;this.build(!e);return this}};for(k in p)c[k]=r(p[k]);p={query:"?",fragment:"#"};r=function(a,b){return function(e,d){if(void 0===e)return this._parts[a]|| -"";null!==e&&(e+="",e.charAt(0)===b&&(e=e.substring(1)));this._parts[a]=e;this.build(!d);return this}};for(k in p)c[k]=r(k,p[k]);p={search:["?","query"],hash:["#","fragment"]};r=function(a,b){return function(e,d){var c=this[a](e,d);return"string"===typeof c&&c.length?b+c:c}};for(k in p)c[k]=r(p[k][1],p[k][0]);c.pathname=function(a,b){if(void 0===a||!0===a){var e=this._parts.path||(this._parts.urn?"":"/");return a?d.decodePath(e):e}this._parts.path=a?d.recodePath(a):"/";this.build(!b);return this}; -c.path=c.pathname;c.href=function(a,b){var e;if(void 0===a)return this.toString();this._string="";this._parts=d._parts();var c=a instanceof d,h="object"===typeof a&&(a.hostname||a.path);!c&&(h&&void 0!==a.pathname)&&(a=a.toString());if("string"===typeof a)this._parts=d.parse(a,this._parts);else if(c||h)for(e in c=c?a._parts:a,c)n.call(this._parts,e)&&(this._parts[e]=c[e]);else throw new TypeError("invalid input");this.build(!b);return this};c.is=function(a){var b=!1,e=!1,c=!1,h=!1,f=!1,g=!1,n=!1, -k=!this._parts.urn;this._parts.hostname&&(k=!1,e=d.ip4_expression.test(this._parts.hostname),c=d.ip6_expression.test(this._parts.hostname),b=e||c,f=(h=!b)&&j&&j.has(this._parts.hostname),g=h&&d.idn_expression.test(this._parts.hostname),n=h&&d.punycode_expression.test(this._parts.hostname));switch(a.toLowerCase()){case "relative":return k;case "absolute":return!k;case "domain":case "name":return h;case "sld":return f;case "ip":return b;case "ip4":case "ipv4":case "inet4":return e;case "ip6":case "ipv6":case "inet6":return c; -case "idn":return g;case "url":return!this._parts.urn;case "urn":return!!this._parts.urn;case "punycode":return n}return null};var q=c.protocol,l=c.port,v=c.hostname;c.protocol=function(a,b){if(void 0!==a&&a&&(a=a.replace(/:(\/\/)?$/,""),a.match(/[^a-zA-z0-9\.+-]/)))throw new TypeError("Protocol '"+a+"' contains characters other than [A-Z0-9.+-]");return q.call(this,a,b)};c.scheme=c.protocol;c.port=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0!==a&&(0===a&&(a=null),a&&(a+="", -":"===a.charAt(0)&&(a=a.substring(1)),a.match(/[^0-9]/))))throw new TypeError("Port '"+a+"' contains characters other than [0-9]");return l.call(this,a,b)};c.hostname=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0!==a){var e={};d.parseHost(a,e);a=e.hostname}return v.call(this,a,b)};c.host=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a)return this._parts.hostname?d.buildHost(this._parts):"";d.parseHost(a,this._parts);this.build(!b);return this};c.authority= -function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a)return this._parts.hostname?d.buildAuthority(this._parts):"";d.parseAuthority(a,this._parts);this.build(!b);return this};c.userinfo=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){if(!this._parts.username)return"";var e=d.buildUserinfo(this._parts);return e.substring(0,e.length-1)}"@"!==a[a.length-1]&&(a+="@");d.parseUserinfo(a,this._parts);this.build(!b);return this};c.resource=function(a,b){var e; -if(void 0===a)return this.path()+this.search()+this.hash();e=d.parse(a);this._parts.path=e.path;this._parts.query=e.query;this._parts.fragment=e.fragment;this.build(!b);return this};c.subdomain=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var e=this._parts.hostname.length-this.domain().length-1;return this._parts.hostname.substring(0,e)||""}e=this._parts.hostname.length-this.domain().length;e=this._parts.hostname.substring(0, -e);e=RegExp("^"+m(e));a&&"."!==a.charAt(a.length-1)&&(a+=".");a&&d.ensureValidHostname(a);this._parts.hostname=this._parts.hostname.replace(e,a);this.build(!b);return this};c.domain=function(a,b){if(this._parts.urn)return void 0===a?"":this;"boolean"===typeof a&&(b=a,a=void 0);if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var e=this._parts.hostname.match(/\./g);if(e&&2>e.length)return this._parts.hostname;e=this._parts.hostname.length-this.tld(b).length-1;e=this._parts.hostname.lastIndexOf(".", -e-1)+1;return this._parts.hostname.substring(e)||""}if(!a)throw new TypeError("cannot set domain empty");d.ensureValidHostname(a);!this._parts.hostname||this.is("IP")?this._parts.hostname=a:(e=RegExp(m(this.domain())+"$"),this._parts.hostname=this._parts.hostname.replace(e,a));this.build(!b);return this};c.tld=function(a,b){if(this._parts.urn)return void 0===a?"":this;"boolean"===typeof a&&(b=a,a=void 0);if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var e=this._parts.hostname.lastIndexOf("."), -e=this._parts.hostname.substring(e+1);return!0!==b&&j&&j.list[e.toLowerCase()]?j.get(this._parts.hostname)||e:e}if(a)if(a.match(/[^a-zA-Z0-9-]/))if(j&&j.is(a))e=RegExp(m(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(e,a);else throw new TypeError("TLD '"+a+"' contains characters other than [A-Z0-9]");else{if(!this._parts.hostname||this.is("IP"))throw new ReferenceError("cannot set TLD on non-domain host");e=RegExp(m(this.tld())+"$");this._parts.hostname=this._parts.hostname.replace(e, -a)}else throw new TypeError("cannot set TLD empty");this.build(!b);return this};c.directory=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path&&!this._parts.hostname)return"";if("/"===this._parts.path)return"/";var e=this._parts.path.length-this.filename().length-1,e=this._parts.path.substring(0,e)||(this._parts.hostname?"/":"");return a?d.decodePath(e):e}e=this._parts.path.length-this.filename().length;e=this._parts.path.substring(0,e);e=RegExp("^"+ -m(e));this.is("relative")||(a||(a="/"),"/"!==a.charAt(0)&&(a="/"+a));a&&"/"!==a.charAt(a.length-1)&&(a+="/");a=d.recodePath(a);this._parts.path=this._parts.path.replace(e,a);this.build(!b);return this};c.filename=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path||"/"===this._parts.path)return"";var e=this._parts.path.lastIndexOf("/"),e=this._parts.path.substring(e+1);return a?d.decodePathSegment(e):e}e=!1;"/"===a.charAt(0)&&(a=a.substring(1));a.match(/\.?\//)&& -(e=!0);var c=RegExp(m(this.filename())+"$");a=d.recodePath(a);this._parts.path=this._parts.path.replace(c,a);e?this.normalizePath(b):this.build(!b);return this};c.suffix=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path||"/"===this._parts.path)return"";var e=this.filename(),c=e.lastIndexOf(".");if(-1===c)return"";e=e.substring(c+1);e=/^[a-z0-9%]+$/i.test(e)?e:"";return a?d.decodePathSegment(e):e}"."===a.charAt(0)&&(a=a.substring(1));if(e=this.suffix())c= -a?RegExp(m(e)+"$"):RegExp(m("."+e)+"$");else{if(!a)return this;this._parts.path+="."+d.recodePath(a)}c&&(a=d.recodePath(a),this._parts.path=this._parts.path.replace(c,a));this.build(!b);return this};c.segment=function(a,b,e){var d=this._parts.urn?":":"/",c=this.path(),h="/"===c.substring(0,1),c=c.split(d);"number"!==typeof a&&(e=b,b=a,a=void 0);if(void 0!==a&&"number"!==typeof a)throw Error("Bad segment '"+a+"', must be 0-based integer");h&&c.shift();0>a&&(a=Math.max(c.length+a,0));if(void 0===b)return void 0=== -a?c:c[a];if(null===a||void 0===c[a])if(u(b))c=b;else{if(b||"string"===typeof b&&b.length)""===c[c.length-1]?c[c.length-1]=b:c.push(b)}else b||"string"===typeof b&&b.length?c[a]=b:c.splice(a,1);h&&c.unshift("");return this.path(c.join(d),e)};var t=c.query;c.query=function(a,b){if(!0===a)return d.parseQuery(this._parts.query);if("function"===typeof a){var e=d.parseQuery(this._parts.query),c=a.call(this,e);this._parts.query=d.buildQuery(c||e,this._parts.duplicateQueryParameters);this.build(!b);return this}return void 0!== -a&&"string"!==typeof a?(this._parts.query=d.buildQuery(a,this._parts.duplicateQueryParameters),this.build(!b),this):t.call(this,a,b)};c.setQuery=function(a,b,e){var c=d.parseQuery(this._parts.query);if("object"===typeof a)for(var h in a)n.call(a,h)&&(c[h]=a[h]);else if("string"===typeof a)c[a]=void 0!==b?b:null;else throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");this._parts.query=d.buildQuery(c,this._parts.duplicateQueryParameters);"string"!==typeof a&&(e=b); -this.build(!e);return this};c.addQuery=function(a,b,e){var c=d.parseQuery(this._parts.query);d.addQuery(c,a,void 0===b?null:b);this._parts.query=d.buildQuery(c,this._parts.duplicateQueryParameters);"string"!==typeof a&&(e=b);this.build(!e);return this};c.removeQuery=function(a,b,e){var c=d.parseQuery(this._parts.query);d.removeQuery(c,a,b);this._parts.query=d.buildQuery(c,this._parts.duplicateQueryParameters);"string"!==typeof a&&(e=b);this.build(!e);return this};c.setSearch=c.setQuery;c.addSearch= -c.addQuery;c.removeSearch=c.removeQuery;c.normalize=function(){return this._parts.urn?this.normalizeProtocol(!1).normalizeQuery(!1).normalizeFragment(!1).build():this.normalizeProtocol(!1).normalizeHostname(!1).normalizePort(!1).normalizePath(!1).normalizeQuery(!1).normalizeFragment(!1).build()};c.normalizeProtocol=function(a){"string"===typeof this._parts.protocol&&(this._parts.protocol=this._parts.protocol.toLowerCase(),this.build(!a));return this};c.normalizeHostname=function(a){this._parts.hostname&& -(this.is("IDN")&&f?this._parts.hostname=f.toASCII(this._parts.hostname):this.is("IPv6")&&g&&(this._parts.hostname=g.best(this._parts.hostname)),this._parts.hostname=this._parts.hostname.toLowerCase(),this.build(!a));return this};c.normalizePort=function(a){"string"===typeof this._parts.protocol&&this._parts.port===d.defaultPorts[this._parts.protocol]&&(this._parts.port=null,this.build(!a));return this};c.normalizePath=function(a){if(this._parts.urn||!this._parts.path||"/"===this._parts.path)return this; -var b,e,c=this._parts.path,h,f;"/"!==c.charAt(0)&&("."===c.charAt(0)&&(e=c.substring(0,c.indexOf("/"))),b=!0,c="/"+c);for(c=c.replace(/(\/(\.\/)+)|\/{2,}/g,"/");;){h=c.indexOf("/../");if(-1===h)break;else if(0===h){c=c.substring(3);break}f=c.substring(0,h).lastIndexOf("/");-1===f&&(f=h);c=c.substring(0,f)+c.substring(h+3)}b&&this.is("relative")&&(c=e?e+c:c.substring(1));c=d.recodePath(c);this._parts.path=c;this.build(!a);return this};c.normalizePathname=c.normalizePath;c.normalizeQuery=function(a){"string"=== -typeof this._parts.query&&(this._parts.query.length?this.query(d.parseQuery(this._parts.query)):this._parts.query=null,this.build(!a));return this};c.normalizeFragment=function(a){this._parts.fragment||(this._parts.fragment=null,this.build(!a));return this};c.normalizeSearch=c.normalizeQuery;c.normalizeHash=c.normalizeFragment;c.iso8859=function(){var a=d.encode,b=d.decode;d.encode=escape;d.decode=decodeURIComponent;this.normalize();d.encode=a;d.decode=b;return this};c.unicode=function(){var a=d.encode, -b=d.decode;d.encode=h;d.decode=unescape;this.normalize();d.encode=a;d.decode=b;return this};c.readable=function(){var a=this.clone();a.username("").password("").normalize();var b="";a._parts.protocol&&(b+=a._parts.protocol+"://");a._parts.hostname&&(a.is("punycode")&&f?(b+=f.toUnicode(a._parts.hostname),a._parts.port&&(b+=":"+a._parts.port)):b+=a.host());a._parts.hostname&&(a._parts.path&&"/"!==a._parts.path.charAt(0))&&(b+="/");b+=a.path(!0);if(a._parts.query){for(var c="",h=0,g=a._parts.query.split("&"), -n=g.length;h]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?\u00ab\u00bb\u201c\u201d\u2018\u2019]))/ig;c.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"};c.invalid_hostname_characters=/[^a-zA-Z0-9\.-]/;c.encode=y;c.decode=decodeURIComponent;c.iso8859=function(){c.encode=escape;c.decode=unescape};c.unicode=function(){c.encode= +y;c.decode=decodeURIComponent};c.characters={pathname:{encode:{expression:/%(24|26|2B|2C|3B|3D|3A|40)/ig,map:{"%24":"$","%26":"&","%2B":"+","%2C":",","%3B":";","%3D":"=","%3A":":","%40":"@"}},decode:{expression:/[\/\?#]/g,map:{"/":"%2F","?":"%3F","#":"%23"}}},reserved:{encode:{expression:/%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/ig,map:{"%3A":":","%2F":"/","%3F":"?","%23":"#","%5B":"[","%5D":"]","%40":"@","%21":"!","%24":"$","%26":"&","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+", +"%2C":",","%3B":";","%3D":"="}}}};c.encodeQuery=function(a){return c.encode(a+"").replace(/%20/g,"+")};c.decodeQuery=function(a){return c.decode((a+"").replace(/\+/g,"%20"))};c.recodePath=function(a){a=(a+"").split("/");for(var b=0,d=a.length;bc)return a.charAt(0)===b.charAt(0)&&"/"===a.charAt(0)?"/":"";"/"!==a.charAt(c)&&(c=a.substring(0,c).lastIndexOf("/"));return a.substring(0,c+1)};c.withinString=function(a,b){return a.replace(c.find_uri_expression,b)};c.ensureValidHostname=function(a){if(a.match(c.invalid_hostname_characters)){if(!f)throw new TypeError("Hostname '"+a+"' contains characters other than [A-Z0-9.-] and Punycode.js is not available");if(f.toASCII(a).match(c.invalid_hostname_characters))throw new TypeError("Hostname '"+ +a+"' contains characters other than [A-Z0-9.-]");}};e.build=function(a){if(!0===a)this._deferred_build=!0;else if(void 0===a||this._deferred_build)this._string=c.build(this._parts),this._deferred_build=!1;return this};e.clone=function(){return new c(this)};e.valueOf=e.toString=function(){return this.build(!1)._string};n={protocol:"protocol",username:"username",password:"password",hostname:"hostname",port:"port"};w=function(a){return function(b,d){if(void 0===b)return this._parts[a]||"";this._parts[a]= +b;this.build(!d);return this}};for(l in n)e[l]=w(n[l]);n={query:"?",fragment:"#"};w=function(a,b){return function(d,c){if(void 0===d)return this._parts[a]||"";null!==d&&(d+="",d.charAt(0)===b&&(d=d.substring(1)));this._parts[a]=d;this.build(!c);return this}};for(l in n)e[l]=w(l,n[l]);n={search:["?","query"],hash:["#","fragment"]};w=function(a,b){return function(d,c){var e=this[a](d,c);return"string"===typeof e&&e.length?b+e:e}};for(l in n)e[l]=w(n[l][1],n[l][0]);e.pathname=function(a,b){if(void 0=== +a||!0===a){var d=this._parts.path||(this._parts.urn?"":"/");return a?c.decodePath(d):d}this._parts.path=a?c.recodePath(a):"/";this.build(!b);return this};e.path=e.pathname;e.href=function(a,b){var d;if(void 0===a)return this.toString();this._string="";this._parts=c._parts();var k=a instanceof c,e="object"===typeof a&&(a.hostname||a.path);!k&&(e&&void 0!==a.pathname)&&(a=a.toString());if("string"===typeof a)this._parts=c.parse(a,this._parts);else if(k||e)for(d in k=k?a._parts:a,k)q.call(this._parts, +d)&&(this._parts[d]=k[d]);else throw new TypeError("invalid input");this.build(!b);return this};e.is=function(a){var b=!1,d=!1,k=!1,e=!1,f=!1,s=!1,h=!1,g=!this._parts.urn;this._parts.hostname&&(g=!1,d=c.ip4_expression.test(this._parts.hostname),k=c.ip6_expression.test(this._parts.hostname),b=d||k,f=(e=!b)&&j&&j.has(this._parts.hostname),s=e&&c.idn_expression.test(this._parts.hostname),h=e&&c.punycode_expression.test(this._parts.hostname));switch(a.toLowerCase()){case "relative":return g;case "absolute":return!g; +case "domain":case "name":return e;case "sld":return f;case "ip":return b;case "ip4":case "ipv4":case "inet4":return d;case "ip6":case "ipv6":case "inet6":return k;case "idn":return s;case "url":return!this._parts.urn;case "urn":return!!this._parts.urn;case "punycode":return h}return null};var x=e.protocol,u=e.port,B=e.hostname;e.protocol=function(a,b){if(void 0!==a&&a&&(a=a.replace(/:(\/\/)?$/,""),a.match(/[^a-zA-z0-9\.+-]/)))throw new TypeError("Protocol '"+a+"' contains characters other than [A-Z0-9.+-]"); +return x.call(this,a,b)};e.scheme=e.protocol;e.port=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0!==a&&(0===a&&(a=null),a&&(a+="",":"===a.charAt(0)&&(a=a.substring(1)),a.match(/[^0-9]/))))throw new TypeError("Port '"+a+"' contains characters other than [0-9]");return u.call(this,a,b)};e.hostname=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0!==a){var d={};c.parseHost(a,d);a=d.hostname}return B.call(this,a,b)};e.host=function(a,b){if(this._parts.urn)return void 0=== +a?"":this;if(void 0===a)return this._parts.hostname?c.buildHost(this._parts):"";c.parseHost(a,this._parts);this.build(!b);return this};e.authority=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a)return this._parts.hostname?c.buildAuthority(this._parts):"";c.parseAuthority(a,this._parts);this.build(!b);return this};e.userinfo=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){if(!this._parts.username)return"";var d=c.buildUserinfo(this._parts);return d.substring(0, +d.length-1)}"@"!==a[a.length-1]&&(a+="@");c.parseUserinfo(a,this._parts);this.build(!b);return this};e.resource=function(a,b){var d;if(void 0===a)return this.path()+this.search()+this.hash();d=c.parse(a);this._parts.path=d.path;this._parts.query=d.query;this._parts.fragment=d.fragment;this.build(!b);return this};e.subdomain=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var d=this._parts.hostname.length-this.domain().length- +1;return this._parts.hostname.substring(0,d)||""}d=this._parts.hostname.length-this.domain().length;d=this._parts.hostname.substring(0,d);d=RegExp("^"+r(d));a&&"."!==a.charAt(a.length-1)&&(a+=".");a&&c.ensureValidHostname(a);this._parts.hostname=this._parts.hostname.replace(d,a);this.build(!b);return this};e.domain=function(a,b){if(this._parts.urn)return void 0===a?"":this;"boolean"===typeof a&&(b=a,a=void 0);if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var d=this._parts.hostname.match(/\./g); +if(d&&2>d.length)return this._parts.hostname;d=this._parts.hostname.length-this.tld(b).length-1;d=this._parts.hostname.lastIndexOf(".",d-1)+1;return this._parts.hostname.substring(d)||""}if(!a)throw new TypeError("cannot set domain empty");c.ensureValidHostname(a);!this._parts.hostname||this.is("IP")?this._parts.hostname=a:(d=RegExp(r(this.domain())+"$"),this._parts.hostname=this._parts.hostname.replace(d,a));this.build(!b);return this};e.tld=function(a,b){if(this._parts.urn)return void 0===a?"": +this;"boolean"===typeof a&&(b=a,a=void 0);if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var d=this._parts.hostname.lastIndexOf("."),d=this._parts.hostname.substring(d+1);return!0!==b&&j&&j.list[d.toLowerCase()]?j.get(this._parts.hostname)||d:d}if(a)if(a.match(/[^a-zA-Z0-9-]/))if(j&&j.is(a))d=RegExp(r(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(d,a);else throw new TypeError("TLD '"+a+"' contains characters other than [A-Z0-9]");else{if(!this._parts.hostname|| +this.is("IP"))throw new ReferenceError("cannot set TLD on non-domain host");d=RegExp(r(this.tld())+"$");this._parts.hostname=this._parts.hostname.replace(d,a)}else throw new TypeError("cannot set TLD empty");this.build(!b);return this};e.directory=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path&&!this._parts.hostname)return"";if("/"===this._parts.path)return"/";var d=this._parts.path.length-this.filename().length-1,d=this._parts.path.substring(0, +d)||(this._parts.hostname?"/":"");return a?c.decodePath(d):d}d=this._parts.path.length-this.filename().length;d=this._parts.path.substring(0,d);d=RegExp("^"+r(d));this.is("relative")||(a||(a="/"),"/"!==a.charAt(0)&&(a="/"+a));a&&"/"!==a.charAt(a.length-1)&&(a+="/");a=c.recodePath(a);this._parts.path=this._parts.path.replace(d,a);this.build(!b);return this};e.filename=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path||"/"===this._parts.path)return""; +var d=this._parts.path.lastIndexOf("/"),d=this._parts.path.substring(d+1);return a?c.decodePathSegment(d):d}d=!1;"/"===a.charAt(0)&&(a=a.substring(1));a.match(/\.?\//)&&(d=!0);var k=RegExp(r(this.filename())+"$");a=c.recodePath(a);this._parts.path=this._parts.path.replace(k,a);d?this.normalizePath(b):this.build(!b);return this};e.suffix=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path||"/"===this._parts.path)return"";var d=this.filename(),k=d.lastIndexOf("."); +if(-1===k)return"";d=d.substring(k+1);d=/^[a-z0-9%]+$/i.test(d)?d:"";return a?c.decodePathSegment(d):d}"."===a.charAt(0)&&(a=a.substring(1));if(d=this.suffix())k=a?RegExp(r(d)+"$"):RegExp(r("."+d)+"$");else{if(!a)return this;this._parts.path+="."+c.recodePath(a)}k&&(a=c.recodePath(a),this._parts.path=this._parts.path.replace(k,a));this.build(!b);return this};e.segment=function(a,b,d){var c=this._parts.urn?":":"/",e=this.path(),f="/"===e.substring(0,1),e=e.split(c);"number"!==typeof a&&(d=b,b=a,a= +void 0);if(void 0!==a&&"number"!==typeof a)throw Error("Bad segment '"+a+"', must be 0-based integer");f&&e.shift();0>a&&(a=Math.max(e.length+a,0));if(void 0===b)return void 0===a?e:e[a];if(null===a||void 0===e[a])if(s(b))e=b;else{if(b||"string"===typeof b&&b.length)""===e[e.length-1]?e[e.length-1]=b:e.push(b)}else b||"string"===typeof b&&b.length?e[a]=b:e.splice(a,1);f&&e.unshift("");return this.path(e.join(c),d)};var A=e.query;e.query=function(a,b){if(!0===a)return c.parseQuery(this._parts.query); +if("function"===typeof a){var d=c.parseQuery(this._parts.query),e=a.call(this,d);this._parts.query=c.buildQuery(e||d,this._parts.duplicateQueryParameters);this.build(!b);return this}return void 0!==a&&"string"!==typeof a?(this._parts.query=c.buildQuery(a,this._parts.duplicateQueryParameters),this.build(!b),this):A.call(this,a,b)};e.setQuery=function(a,b,d){var e=c.parseQuery(this._parts.query);if("object"===typeof a)for(var f in a)q.call(a,f)&&(e[f]=a[f]);else if("string"===typeof a)e[a]=void 0!== +b?b:null;else throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");this._parts.query=c.buildQuery(e,this._parts.duplicateQueryParameters);"string"!==typeof a&&(d=b);this.build(!d);return this};e.addQuery=function(a,b,d){var e=c.parseQuery(this._parts.query);c.addQuery(e,a,void 0===b?null:b);this._parts.query=c.buildQuery(e,this._parts.duplicateQueryParameters);"string"!==typeof a&&(d=b);this.build(!d);return this};e.removeQuery=function(a,b,d){var e=c.parseQuery(this._parts.query); +c.removeQuery(e,a,b);this._parts.query=c.buildQuery(e,this._parts.duplicateQueryParameters);"string"!==typeof a&&(d=b);this.build(!d);return this};e.hasQuery=function(a,b,d){var e=c.parseQuery(this._parts.query);return c.hasQuery(e,a,b,d)};e.setSearch=e.setQuery;e.addSearch=e.addQuery;e.removeSearch=e.removeQuery;e.hasSearch=e.hasQuery;e.normalize=function(){return this._parts.urn?this.normalizeProtocol(!1).normalizeQuery(!1).normalizeFragment(!1).build():this.normalizeProtocol(!1).normalizeHostname(!1).normalizePort(!1).normalizePath(!1).normalizeQuery(!1).normalizeFragment(!1).build()}; +e.normalizeProtocol=function(a){"string"===typeof this._parts.protocol&&(this._parts.protocol=this._parts.protocol.toLowerCase(),this.build(!a));return this};e.normalizeHostname=function(a){this._parts.hostname&&(this.is("IDN")&&f?this._parts.hostname=f.toASCII(this._parts.hostname):this.is("IPv6")&&g&&(this._parts.hostname=g.best(this._parts.hostname)),this._parts.hostname=this._parts.hostname.toLowerCase(),this.build(!a));return this};e.normalizePort=function(a){"string"===typeof this._parts.protocol&& +this._parts.port===c.defaultPorts[this._parts.protocol]&&(this._parts.port=null,this.build(!a));return this};e.normalizePath=function(a){if(this._parts.urn||!this._parts.path||"/"===this._parts.path)return this;var b,d,e=this._parts.path,f,s;"/"!==e.charAt(0)&&("."===e.charAt(0)&&(d=e.substring(0,e.indexOf("/"))),b=!0,e="/"+e);for(e=e.replace(/(\/(\.\/)+)|\/{2,}/g,"/");;){f=e.indexOf("/../");if(-1===f)break;else if(0===f){e=e.substring(3);break}s=e.substring(0,f).lastIndexOf("/");-1===s&&(s=f);e= +e.substring(0,s)+e.substring(f+3)}b&&this.is("relative")&&(e=d?d+e:e.substring(1));e=c.recodePath(e);this._parts.path=e;this.build(!a);return this};e.normalizePathname=e.normalizePath;e.normalizeQuery=function(a){"string"===typeof this._parts.query&&(this._parts.query.length?this.query(c.parseQuery(this._parts.query)):this._parts.query=null,this.build(!a));return this};e.normalizeFragment=function(a){this._parts.fragment||(this._parts.fragment=null,this.build(!a));return this};e.normalizeSearch=e.normalizeQuery; +e.normalizeHash=e.normalizeFragment;e.iso8859=function(){var a=c.encode,b=c.decode;c.encode=escape;c.decode=decodeURIComponent;this.normalize();c.encode=a;c.decode=b;return this};e.unicode=function(){var a=c.encode,b=c.decode;c.encode=y;c.decode=unescape;this.normalize();c.encode=a;c.decode=b;return this};e.readable=function(){var a=this.clone();a.username("").password("").normalize();var b="";a._parts.protocol&&(b+=a._parts.protocol+"://");a._parts.hostname&&(a.is("punycode")&&f?(b+=f.toUnicode(a._parts.hostname), +a._parts.port&&(b+=":"+a._parts.port)):b+=a.host());a._parts.hostname&&(a._parts.path&&"/"!==a._parts.path.charAt(0))&&(b+="/");b+=a.path(!0);if(a._parts.query){for(var d="",e=0,s=a._parts.query.split("&"),g=s.length;e