Skip to content

Instantly share code, notes, and snippets.

@chiefjester
Forked from Celestz/urlparser-bundled.js
Last active October 31, 2015 06:01
Show Gist options
  • Save chiefjester/54314757b00f62e717fb to your computer and use it in GitHub Desktop.
Save chiefjester/54314757b00f62e717fb to your computer and use it in GitHub Desktop.
!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){(function(a){!function(d){function z(a){throw RangeError(u[a])}function A(a,b){for(var c=a.length,d=[];c--;)d[c]=b(a[c]);return d}function B(a,b){var c=a.split("@"),d="";c.length>1&&(d=c[0]+"@",a=c[1]),a=a.replace(t,".");var e=a.split("."),f=A(e,b).join(".");return d+f}function C(a){for(var e,f,b=[],c=0,d=a.length;d>c;)e=a.charCodeAt(c++),e>=55296&&56319>=e&&d>c?(f=a.charCodeAt(c++),56320==(64512&f)?b.push(((1023&e)<<10)+(1023&f)+65536):(b.push(e),c--)):b.push(e);return b}function D(a){return A(a,function(a){var b="";return a>65535&&(a-=65536,b+=x(a>>>10&1023|55296),a=56320|1023&a),b+=x(a)}).join("")}function E(a){return 10>a-48?a-22:26>a-65?a-65:26>a-97?a-97:j}function F(a,b){return a+22+75*(26>a)-((0!=b)<<5)}function G(a,b,c){var d=0;for(a=c?w(a/n):a>>1,a+=w(a/b);a>v*l>>1;d+=j)a=w(a/v);return w(d+(v+1)*a/(a+m))}function H(a){var d,h,m,n,r,s,t,u,v,x,b=[],c=a.length,e=0,f=p,g=o;for(h=a.lastIndexOf(q),0>h&&(h=0),m=0;h>m;++m)a.charCodeAt(m)>=128&&z("not-basic"),b.push(a.charCodeAt(m));for(n=h>0?h+1:0;c>n;){for(r=e,s=1,t=j;n>=c&&z("invalid-input"),u=E(a.charCodeAt(n++)),(u>=j||u>w((i-e)/s))&&z("overflow"),e+=u*s,v=g>=t?k:t>=g+l?l:t-g,!(v>u);t+=j)x=j-v,s>w(i/x)&&z("overflow"),s*=x;d=b.length+1,g=G(e-r,d,0==r),w(e/d)>i-f&&z("overflow"),f+=w(e/d),e%=d,b.splice(e++,0,f)}return D(b)}function I(a){var b,c,d,e,f,g,h,m,n,r,s,u,v,y,A,t=[];for(a=C(a),u=a.length,b=p,c=0,f=o,g=0;u>g;++g)s=a[g],128>s&&t.push(x(s));for(d=e=t.length,e&&t.push(q);u>d;){for(h=i,g=0;u>g;++g)s=a[g],s>=b&&h>s&&(h=s);for(v=d+1,h-b>w((i-c)/v)&&z("overflow"),c+=(h-b)*v,b=h,g=0;u>g;++g)if(s=a[g],b>s&&++c>i&&z("overflow"),s==b){for(m=c,n=j;r=f>=n?k:n>=f+l?l:n-f,!(r>m);n+=j)A=m-r,y=j-r,t.push(x(F(r+A%y,0))),m=w(A/y);t.push(x(F(m,0))),f=G(c,v,d==e),c=0,++d}++c,++b}return t.join("")}function J(a){return B(a,function(a){return r.test(a)?H(a.slice(4).toLowerCase()):a})}function K(a){return B(a,function(a){return s.test(a)?"xn--"+I(a):a})}var e="object"==typeof c&&c&&!c.nodeType&&c,f="object"==typeof b&&b&&!b.nodeType&&b,g="object"==typeof a&&a;(g.global===g||g.window===g||g.self===g)&&(d=g);var h,y,i=2147483647,j=36,k=1,l=26,m=38,n=700,o=72,p=128,q="-",r=/^xn--/,s=/[^\x20-\x7E]/,t=/[\x2E\u3002\uFF0E\uFF61]/g,u={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},v=j-k,w=Math.floor,x=String.fromCharCode;if(h={version:"1.3.2",ucs2:{decode:C,encode:D},decode:H,encode:I,toASCII:K,toUnicode:J},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",function(){return h});else if(e&&f)if(b.exports==e)f.exports=h;else for(y in h)h.hasOwnProperty(y)&&(e[y]=h[y]);else d.punycode=h}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(a,b,c){"use strict";function d(a,b){return Object.prototype.hasOwnProperty.call(a,b)}b.exports=function(a,b,c,f){b=b||"&",c=c||"=";var g={};if("string"!=typeof a||0===a.length)return g;var h=/\+/g;a=a.split(b);var i=1e3;f&&"number"==typeof f.maxKeys&&(i=f.maxKeys);var j=a.length;i>0&&j>i&&(j=i);for(var k=0;j>k;++k){var n,o,p,q,l=a[k].replace(h,"%20"),m=l.indexOf(c);m>=0?(n=l.substr(0,m),o=l.substr(m+1)):(n=l,o=""),p=decodeURIComponent(n),q=decodeURIComponent(o),d(g,p)?e(g[p])?g[p].push(q):g[p]=[g[p],q]:g[p]=q}return g};var e=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)}},{}],3:[function(a,b,c){"use strict";function f(a,b){if(a.map)return a.map(b);for(var c=[],d=0;d<a.length;d++)c.push(b(a[d],d));return c}var d=function(a){switch(typeof a){case"string":return a;case"boolean":return a?"true":"false";case"number":return isFinite(a)?a:"";default:return""}};b.exports=function(a,b,c,h){return b=b||"&",c=c||"=",null===a&&(a=void 0),"object"==typeof a?f(g(a),function(g){var h=encodeURIComponent(d(g))+c;return e(a[g])?f(a[g],function(a){return h+encodeURIComponent(d(a))}).join(b):h+encodeURIComponent(d(a[g]))}).join(b):h?encodeURIComponent(d(h))+c+encodeURIComponent(d(a)):""};var e=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)},g=Object.keys||function(a){var b=[];for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&b.push(c);return b}},{}],4:[function(a,b,c){"use strict";c.decode=c.parse=a("./decode"),c.encode=c.stringify=a("./encode")},{"./decode":2,"./encode":3}],5:[function(a,b,c){"use strict";function d(){this._protocol=null,this._href="",this._port=-1,this._query=null,this.auth=null,this.slashes=null,this.host=null,this.hostname=null,this.hash=null,this.search=null,this.pathname=null,this._prependSlash=!1}function i(a){return a.replace(/[?#]/g,function(a){return encodeURIComponent(a)})}function j(a){return a.replace(/#/g,function(a){return encodeURIComponent(a)})}function k(a,b,c,d){for(var e=a.length,f=c;e>f;++f){var g=a.charCodeAt(f);if(g===b)return!0;if(1===d[g])return!1}return!1}function l(a,b,c){for(var d=0,e=a.length;e>d;++d){var f=a.charCodeAt(d);if(f===b||f===c)return!0}return!1}function m(a){var b=new Uint8Array(128);return a.forEach(function(a){if("number"==typeof a)b[a]=1;else for(var c=a[0],d=a[1],e=c;d>=e;++e)b[e]=1}),b}function v(){}var e=a("querystring");d.queryString=e,d.prototype.parse=function(a,b,c,e){if("string"!=typeof a)throw new TypeError("Parameter 'url' must be a string, not "+typeof a);for(var f=0,g=a.length-1;a.charCodeAt(f)<=32;)f++;for(;a.charCodeAt(g)<=32;)g--;if(f=this._parseProtocol(a,f,g),"javascript"!==this._protocol){f=this._parseHost(a,f,g,c);var h=this._protocol;!this.hostname&&(this.slashes||h&&!u[h])&&(this.hostname=this.host="")}if(g>=f){var i=a.charCodeAt(f);47===i||92===i?this._parsePath(a,f,g,e):63===i?this._parseQuery(a,f,g,e):35===i?this._parseHash(a,f,g,e):"javascript"!==this._protocol?this._parsePath(a,f,g,e):this.pathname=a.slice(f,g+1)}if(!this.pathname&&this.hostname&&this._slashProtocols[this._protocol]&&(this.pathname="/"),b){var j=this.search;null==j&&(j=this.search=""),63===j.charCodeAt(0)&&(j=j.slice(1)),this.query=d.queryString.parse(j)}},d.prototype.resolve=function(a){return this.resolveObject(d.parse(a,!1,!0)).format()},d.prototype.format=function(){var a=this.auth||"";a&&(a=encodeURIComponent(a),a=a.replace(/%3A/i,":"),a+="@");var b=this.protocol||"",c=this.pathname||"",e=this.hash||"",f=this.search||"",i="",j=this.hostname||"",k=this.port||"",l=!1,m="",n=this.query;if(n&&"object"==typeof n&&(i=d.queryString.stringify(n)),f||(f=i?"?"+i:""),b&&58!==b.charCodeAt(b.length-1)&&(b+=":"),this.host)l=a+this.host;else if(j){var o=j.indexOf(":")>-1;o&&(j="["+j+"]"),l=a+j+(k?":"+k:"")}var p=this.slashes||(!b||u[b])&&l!==!1;return b?m=b+(p?"//":""):p&&(m="//"),p&&c&&47!==c.charCodeAt(0)&&(c="/"+c),f&&63!==f.charCodeAt(0)&&(f="?"+f),e&&35!==e.charCodeAt(0)&&(e="#"+e),c=g(c),f=h(f),m+(l===!1?"":l)+c+f+e},d.prototype.resolveObject=function(a){"string"==typeof a&&(a=d.parse(a,!1,!0));var b=this._clone();if(b.hash=a.hash,!a.href)return b._href="",b;if(a.slashes&&!a._protocol)return a._copyPropsTo(b,!0),u[b._protocol]&&b.hostname&&!b.pathname&&(b.pathname="/"),b._href="",b;if(a._protocol&&a._protocol!==b._protocol){if(!u[a._protocol])return a._copyPropsTo(b,!1),b._href="",b;if(b._protocol=a._protocol,a.host||"javascript"===a._protocol)b.pathname=a.pathname;else{for(var c=(a.pathname||"").split("/");c.length&&!(a.host=c.shift()););a.host||(a.host=""),a.hostname||(a.hostname=""),""!==c[0]&&c.unshift(""),c.length<2&&c.unshift(""),b.pathname=c.join("/")}return b.search=a.search,b.host=a.host||"",b.auth=a.auth,b.hostname=a.hostname||a.host,b._port=a._port,b.slashes=b.slashes||a.slashes,b._href="",b}var e=b.pathname&&47===b.pathname.charCodeAt(0),f=a.host||a.pathname&&47===a.pathname.charCodeAt(0),g=f||e||b.host&&a.pathname,h=g,i=b.pathname&&b.pathname.split("/")||[],c=a.pathname&&a.pathname.split("/")||[],j=b._protocol&&!u[b._protocol];if(j&&(b.hostname="",b._port=-1,b.host&&(""===i[0]?i[0]=b.host:i.unshift(b.host)),b.host="",a._protocol&&(a.hostname="",a._port=-1,a.host&&(""===c[0]?c[0]=a.host:c.unshift(a.host)),a.host=""),g=g&&(""===c[0]||""===i[0])),f)b.host=a.host?a.host:b.host,b.hostname=a.hostname?a.hostname:b.hostname,b.search=a.search,i=c;else if(c.length)i||(i=[]),i.pop(),i=i.concat(c),b.search=a.search;else if(a.search){if(j){b.hostname=b.host=i.shift();var k=b.host&&b.host.indexOf("@")>0?b.host.split("@"):!1;k&&(b.auth=k.shift(),b.host=b.hostname=k.shift())}return b.search=a.search,b._href="",b}if(!i.length)return b.pathname=null,b._href="",b;for(var l=i.slice(-1)[0],m=(b.host||a.host)&&("."===l||".."===l)||""===l,n=0,o=i.length;o>=0;o--)l=i[o],"."===l?i.splice(o,1):".."===l?(i.splice(o,1),n++):n&&(i.splice(o,1),n--);if(!g&&!h)for(;n--;n)i.unshift("..");!g||""===i[0]||i[0]&&47===i[0].charCodeAt(0)||i.unshift(""),m&&"/"!==i.join("/").substr(-1)&&i.push("");var p=""===i[0]||i[0]&&47===i[0].charCodeAt(0);if(j){b.hostname=b.host=p?"":i.length?i.shift():"";var k=b.host&&b.host.indexOf("@")>0?b.host.split("@"):!1;k&&(b.auth=k.shift(),b.host=b.hostname=k.shift())}return g=g||b.host&&i.length,g&&!p&&i.unshift(""),b.pathname=0===i.length?null:i.join("/"),b.auth=a.auth||b.auth,b.slashes=b.slashes||a.slashes,b._href="",b};var f=a("punycode");d.prototype._hostIdna=function(a){return f.toASCII(a)};var g=d.prototype._escapePathName=function(a){return l(a,35,63)?i(a):a},h=d.prototype._escapeSearch=function(a){return l(a,35,-1)?j(a):a};d.prototype._parseProtocol=function(a,b,c){for(var d=!1,e=this._protocolCharacters,f=b;c>=f;++f){var g=a.charCodeAt(f);if(58===g){var h=a.slice(b,f);return d&&(h=h.toLowerCase()),this._protocol=h,f+1}if(1!==e[g])return b;97>g&&(d=!0)}return b},d.prototype._parseAuth=function(a,b,c,d){var e=a.slice(b,c+1);d&&(e=decodeURIComponent(e)),this.auth=e},d.prototype._parsePort=function(a,b,c){for(var d=0,e=!1,f=!0,g=b;c>=g;++g){var h=a.charCodeAt(g);if(!(h>=48&&57>=h)){f=!1,(92===h||47===h)&&(f=!0);break}d=10*d+(h-48),e=!0}return 0===d&&!e||!f?(f||(this._port=-2),0):(this._port=d,g-b)},d.prototype._parseHost=function(a,b,c,d){var e=this._hostEndingCharacters,f=a.charCodeAt(b),g=a.charCodeAt(b+1);if(47!==f&&92!==f||47!==g&&92!==g){if(!this._protocol||u[this._protocol])return b}else{if(this.slashes=!0,0===b){if(2>c)return b;var h=k(a,64,2,e);if(!h&&!d)return this.slashes=null,b}b+=2}for(var i=!1,j=!1,l=b,m=c,n=-1,o=0,p=0,q=!1,r=-1,s=b;c>=s;++s){var t=a.charCodeAt(s);if(64===t)r=s;else if(37===t)q=!0;else if(1===e[t])break}if(r>-1&&(this._parseAuth(a,b,r-1,q),b=l=r+1),91===a.charCodeAt(b)){for(var s=b+1;c>=s;++s){var t=a.charCodeAt(s);if(93===t){58===a.charCodeAt(s+1)&&(o=this._parsePort(a,s+2,c)+1);var v=a.slice(b+1,s).toLowerCase();return this.hostname=v,this.host=this._port>0?"["+v+"]:"+this._port:"["+v+"]",this.pathname="/",s+o+1}}return b}for(var s=b;c>=s;++s){if(p>62)return this.hostname=this.host=a.slice(b,s),s;var t=a.charCodeAt(s);if(58===t){o=this._parsePort(a,s+1,c)+1,m=s-1;break}if(97>t){if(46===t)p=-1;else if(t>=65&&90>=t)i=!0;else if(!(45===t||95===t||43===t||t>=48&&57>=t)){0===e[t]&&0===this._noPrependSlashHostEnders[t]&&(this._prependSlash=!0),m=s-1;break}}else if(t>=123){if(126>=t){0===this._noPrependSlashHostEnders[t]&&(this._prependSlash=!0),m=s-1;break}j=!0}n=t,p++}if(m+1!==b&&256>=m-l){var v=a.slice(l,m+1);i&&(v=v.toLowerCase()),j&&(v=this._hostIdna(v)),this.hostname=v,this.host=this._port>0?v+":"+this._port:v}return m+1+o},d.prototype._copyPropsTo=function(a,b){b||(a._protocol=this._protocol),a._href=this._href,a._port=this._port,a._prependSlash=this._prependSlash,a.auth=this.auth,a.slashes=this.slashes,a.host=this.host,a.hostname=this.hostname,a.hash=this.hash,a.search=this.search,a.pathname=this.pathname},d.prototype._clone=function(){var a=new d;return a._protocol=this._protocol,a._href=this._href,a._port=this._port,a._prependSlash=this._prependSlash,a.auth=this.auth,a.slashes=this.slashes,a.host=this.host,a.hostname=this.hostname,a.hash=this.hash,a.search=this.search,a.pathname=this.pathname,a},d.prototype._getComponentEscaped=function(a,b,c,d){for(var e=b,f=b,g="",h=d?this._afterQueryAutoEscapeMap:this._autoEscapeMap;c>=f;++f){var i=a.charCodeAt(f),j=h[i];""!==j&&void 0!==j&&(f>e&&(g+=a.slice(e,f)),g+=j,e=f+1)}return f+1>e&&(g+=a.slice(e,f)),g},d.prototype._parsePath=function(a,b,c,d){for(var e=b,f=c,g=!1,h=this._autoEscapeCharacters,i=-2===this._port?"/:":"",j=b;c>=j;++j){var k=a.charCodeAt(j);if(35===k){this._parseHash(a,j,c,d),f=j-1;break}if(63===k){this._parseQuery(a,j,c,d),f=j-1;break}d||g||1!==h[k]||(g=!0)}if(e>f)return void(this.pathname=""===i?"/":i);var l;l=g?this._getComponentEscaped(a,e,f,!1):a.slice(e,f+1),this.pathname=""===i?this._prependSlash?"/"+l:l:i+l},d.prototype._parseQuery=function(a,b,c,d){for(var e=b,f=c,g=!1,h=this._autoEscapeCharacters,i=b;c>=i;++i){var j=a.charCodeAt(i);if(35===j){this._parseHash(a,i,c,d),f=i-1;break}d||g||1!==h[j]||(g=!0)}if(e>f)return void(this.search="");var k;k=g?this._getComponentEscaped(a,e,f,!0):a.slice(e,f+1),this.search=k},d.prototype._parseHash=function(a,b,c,d){return b>c?void(this.hash=""):void(this.hash=d?a.slice(b,c+1):this._getComponentEscaped(a,b,c,!0))},Object.defineProperty(d.prototype,"port",{get:function(){return this._port>=0?""+this._port:null},set:function(a){null==a?this._port=-1:this._port=parseInt(a,10)}}),Object.defineProperty(d.prototype,"query",{get:function(){var a=this._query;if(null!=a)return a;var b=this.search;return b&&(63===b.charCodeAt(0)&&(b=b.slice(1)),""!==b)?(this._query=b,b):b},set:function(a){this._query=a}}),Object.defineProperty(d.prototype,"path",{get:function(){var a=this.pathname||"",b=this.search||"";return a||b?a+b:null==a&&b?"/"+b:null},set:function(){}}),Object.defineProperty(d.prototype,"protocol",{get:function(){var a=this._protocol;return a?a+":":a},set:function(a){if("string"==typeof a){var b=a.length-1;58===a.charCodeAt(b)?this._protocol=a.slice(0,b):this._protocol=a}else null==a&&(this._protocol=null)}}),Object.defineProperty(d.prototype,"href",{get:function(){var a=this._href;return a||(a=this._href=this.format()),a},set:function(a){this._href=a}}),d.parse=function(a,b,c,e){if(a instanceof d)return a;var f=new d;return f.parse(a,!!b,!!c,!!e),f},d.format=function(a){return"string"==typeof a&&(a=d.parse(a)),a instanceof d?a.format():d.prototype.format.call(a)},d.resolve=function(a,b){return d.parse(a,!1,!0).resolve(b)},d.resolveObject=function(a,b){return a?d.parse(a,!1,!0).resolveObject(b):b};for(var n=["<",">",'"',"`"," ","\r","\n"," ","{","}","|","\\","^","`","'"],o=new Array(128),p=0,q=o.length;q>p;++p)o[p]="";for(var p=0,q=n.length;q>p;++p){var r=n[p],s=encodeURIComponent(r);s===r&&(s=escape(r)),o[r.charCodeAt(0)]=s}var t=o.slice();o[92]="/";var u=d.prototype._slashProtocols={http:!0,https:!0,gopher:!0,file:!0,ftp:!0,"http:":!0,"https:":!0,"gopher:":!0,"file:":!0,"ftp:":!0};v.prototype=u,d.prototype._protocolCharacters=m([[97,122],[65,90],46,43,45]),d.prototype._hostEndingCharacters=m([35,63,47,92]),d.prototype._autoEscapeCharacters=m(n.map(function(a){return a.charCodeAt(0)})),d.prototype._noPrependSlashHostEnders=m(["<",">","'","`"," ","\r","\n"," ","{","}","|","^","`",'"',"%",";"].map(function(a){return a.charCodeAt(0)})),d.prototype._autoEscapeMap=o,d.prototype._afterQueryAutoEscapeMap=t,b.exports=d,d.replace=function(){a.cache.url={exports:d}}},{punycode:1,querystring:4}]},{},[5]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment