From 002cf6867dde7def5994f0a953627362cacbede8 Mon Sep 17 00:00:00 2001 From: Steven D Vachon Date: Sat, 6 Feb 2016 20:00:04 -0500 Subject: [PATCH] v0.6.0 --- .travis.yml | 1 + README.md | 16 ++++++++++------ index-browser.js | 2 +- index.js | 15 +++++++++++++-- package.json | 19 +++++++++---------- test.js | 38 ++++++++++++++++++++++++++++++++++++-- 6 files changed, 70 insertions(+), 21 deletions(-) diff --git a/.travis.yml b/.travis.yml index d5082a9..aa3c554 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,4 +3,5 @@ node_js: - "0.10" - "0.12" - "4" +- "5" script: npm test diff --git a/README.md b/README.md index 695df51..aee0dcf 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ # urlcache [![NPM Version][npm-image]][npm-url] [![Bower Version][bower-image]][bower-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][david-image]][david-url] -> URL key-value cache and store. +> URL key-value cache. ## Installation -[Node.js](http://nodejs.org/) `>= 0.10` is required. To install, type this at the command line: +[Node.js](http://nodejs.org/) `>= 0.10` is required; `< 4.0` will need an `Object.assign` polyfill. To install, type this at the command line: ```shell -npm install urlcache --save-dev +npm install urlcache ``` @@ -22,16 +22,19 @@ var cache = new UrlCache(options); **Note:** all instances of `url` can be either a `String` or a [`url.parse()`](https://nodejs.org/api/url.html#url_url_parse_urlstr_parsequerystring_slashesdenotehost)-compatible `Object`. ### .clear([url]) -Removes `url` from cache. If `url` is not defined, *all* cached key value pairs will be removed. +Removes the `url` key-value pair. If the `url` argument is not defined, *all* pairs will be removed. ### .get(url) Returns the stored value of `url`. If no such value exists, `undefined` will be returned. +### .length() +Returns the number of stored key-value pairs. + ### .set(url, value[, expiryTime]) Stores `value` (any type) into `url` key. Optionally, define `expiryTime` to override `options.expiryTime`. ```js cache.set("url", {"key":"value"}); -cache.get("url"); //-> {"key":"value"} +cache.get("url"); //=> {"key":"value"} cache.set("url", new Promise(function(resolve, reject) { // set value after some delayed event @@ -41,7 +44,7 @@ cache.set("url", new Promise(function(resolve, reject) { }); Promise.resolve(cache.get("url")).then(function(value) { - console.log(value); //-> "value" + console.log(value); //=> "value" }); ``` @@ -70,6 +73,7 @@ When `true`, will remove `#hashes` from URLs. They are most likely not useful to ## Changelog +* 0.6.0 added `.length()` and removed `Object.assign()` polyfill * 0.5.0 removed use of Promises as they were unnecessary * 0.4.0 simpler `Promise`-based API * 0.3.0 added `options.defaultPorts`, more tests diff --git a/index-browser.js b/index-browser.js index 52e9198..a92da81 100644 --- a/index-browser.js +++ b/index-browser.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.UrlCache=t()}}(function(){var t;return function e(t,r,n){function o(s,i){if(!r[s]){if(!t[s]){var h="function"==typeof require&&require;if(!i&&h)return h(s,!0);if(a)return a(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var u=r[s]={exports:{}};t[s][0].call(u.exports,function(e){var r=t[s][1][e];return o(r?r:e)},u,u.exports,e,t,r,n)}return r[s].exports}for(var a="function"==typeof require&&require,s=0;s1&&(n=r[0]+"@",t=r[1]),t=t.replace(w,".");var o=t.split("."),a=s(o,e).join(".");return n+a}function h(t){for(var e,r,n=[],o=0,a=t.length;a>o;)e=t.charCodeAt(o++),e>=55296&&56319>=e&&a>o?(r=t.charCodeAt(o++),56320==(64512&r)?n.push(((1023&e)<<10)+(1023&r)+65536):(n.push(e),o--)):n.push(e);return n}function l(t){return s(t,function(t){var e="";return t>65535&&(t-=65536,e+=_(t>>>10&1023|55296),t=56320|1023&t),e+=_(t)}).join("")}function u(t){return 10>t-48?t-22:26>t-65?t-65:26>t-97?t-97:b}function c(t,e){return t+22+75*(26>t)-((0!=e)<<5)}function f(t,e,r){var n=0;for(t=r?H(t/U):t>>1,t+=H(t/e);t>q*A>>1;n+=b)t=H(t/q);return H(n+(q+1)*t/(t+R))}function p(t){var e,r,n,o,s,i,h,c,p,y,d=[],m=t.length,x=0,v=S,g=j;for(r=t.lastIndexOf(L),0>r&&(r=0),n=0;r>n;++n)t.charCodeAt(n)>=128&&a("not-basic"),d.push(t.charCodeAt(n));for(o=r>0?r+1:0;m>o;){for(s=x,i=1,h=b;o>=m&&a("invalid-input"),c=u(t.charCodeAt(o++)),(c>=b||c>H((T-x)/i))&&a("overflow"),x+=c*i,p=g>=h?I:h>=g+A?A:h-g,!(p>c);h+=b)y=b-p,i>H(T/y)&&a("overflow"),i*=y;e=d.length+1,g=f(x-s,e,0==s),H(x/e)>T-v&&a("overflow"),v+=H(x/e),x%=e,d.splice(x++,0,v)}return l(d)}function y(t){var e,r,n,o,s,i,l,u,p,y,d,m,x,v,g,O=[];for(t=h(t),m=t.length,e=S,r=0,s=j,i=0;m>i;++i)d=t[i],128>d&&O.push(_(d));for(n=o=O.length,o&&O.push(L);m>n;){for(l=T,i=0;m>i;++i)d=t[i],d>=e&&l>d&&(l=d);for(x=n+1,l-e>H((T-r)/x)&&a("overflow"),r+=(l-e)*x,e=l,i=0;m>i;++i)if(d=t[i],e>d&&++r>T&&a("overflow"),d==e){for(u=r,p=b;y=s>=p?I:p>=s+A?A:p-s,!(y>u);p+=b)g=u-y,v=b-y,O.push(_(c(y+g%v,0))),u=H(g/v);O.push(_(c(u,0))),s=f(r,x,n==o),r=0,++n}++r,++e}return O.join("")}function d(t){return i(t,function(t){return C.test(t)?p(t.slice(4).toLowerCase()):t})}function m(t){return i(t,function(t){return D.test(t)?"xn--"+y(t):t})}var x="object"==typeof n&&n&&!n.nodeType&&n,v="object"==typeof r&&r&&!r.nodeType&&r,g="object"==typeof e&&e;(g.global===g||g.window===g||g.self===g)&&(o=g);var O,E,T=2147483647,b=36,I=1,A=26,R=38,U=700,j=72,S=128,L="-",C=/^xn--/,D=/[^\x20-\x7E]/,w=/[\x2E\u3002\uFF0E\uFF61]/g,P={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},q=b-I,H=Math.floor,_=String.fromCharCode;if(O={version:"1.3.2",ucs2:{decode:h,encode:l},decode:p,encode:y,toASCII:m,toUnicode:d},"function"==typeof t&&"object"==typeof t.amd&&t.amd)t("punycode",function(){return O});else if(x&&v)if(r.exports==x)v.exports=O;else for(E in O)O.hasOwnProperty(E)&&(x[E]=O[E]);else o.punycode=O}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],3:[function(t,e,r){"use strict";function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.exports=function(t,e,r,a){e=e||"&",r=r||"=";var s={};if("string"!=typeof t||0===t.length)return s;var i=/\+/g;t=t.split(e);var h=1e3;a&&"number"==typeof a.maxKeys&&(h=a.maxKeys);var l=t.length;h>0&&l>h&&(l=h);for(var u=0;l>u;++u){var c,f,p,y,d=t[u].replace(i,"%20"),m=d.indexOf(r);m>=0?(c=d.substr(0,m),f=d.substr(m+1)):(c=d,f=""),p=decodeURIComponent(c),y=decodeURIComponent(f),n(s,p)?o(s[p])?s[p].push(y):s[p]=[s[p],y]:s[p]=y}return s};var o=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},{}],4:[function(t,e,r){"use strict";function n(t,e){if(t.map)return t.map(e);for(var r=[],n=0;n",'"',"`"," ","\r","\n"," "],m=["{","}","|","\\","^","`"].concat(d),x=["'"].concat(m),v=["%","/","?",";","#"].concat(x),g=["/","?","#"],O=255,E=/^[a-z0-9A-Z_-]{0,63}$/,T=/^([a-z0-9A-Z_-]{0,63})(.*)$/,b={javascript:!0,"javascript:":!0},I={javascript:!0,"javascript:":!0},A={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},R=t("querystring");n.prototype.parse=function(t,e,r){if(!h(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var n=t;n=n.trim();var o=p.exec(n);if(o){o=o[0];var a=o.toLowerCase();this.protocol=a,n=n.substr(o.length)}if(r||o||n.match(/^\/\/[^@\/]+@[^@\/]+/)){var s="//"===n.substr(0,2);!s||o&&I[o]||(n=n.substr(2),this.slashes=!0)}if(!I[o]&&(s||o&&!A[o])){for(var i=-1,l=0;lu)&&(i=u)}var c,y;y=-1===i?n.lastIndexOf("@"):n.lastIndexOf("@",i),-1!==y&&(c=n.slice(0,y),n=n.slice(y+1),this.auth=decodeURIComponent(c)),i=-1;for(var l=0;lu)&&(i=u)}-1===i&&(i=n.length),this.host=n.slice(0,i),n=n.slice(i),this.parseHost(),this.hostname=this.hostname||"";var d="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!d)for(var m=this.hostname.split(/\./),l=0,U=m.length;U>l;l++){var j=m[l];if(j&&!j.match(E)){for(var S="",L=0,C=j.length;C>L;L++)S+=j.charCodeAt(L)>127?"x":j[L];if(!S.match(E)){var D=m.slice(0,l),w=m.slice(l+1),P=j.match(T);P&&(D.push(P[1]),w.unshift(P[2])),w.length&&(n="/"+w.join(".")+n),this.hostname=D.join(".");break}}}if(this.hostname.length>O?this.hostname="":this.hostname=this.hostname.toLowerCase(),!d){for(var q=this.hostname.split("."),H=[],l=0;ll;l++){var M=x[l],V=encodeURIComponent(M);V===M&&(V=escape(M)),n=n.split(M).join(V)}var Y=n.indexOf("#");-1!==Y&&(this.hash=n.substr(Y),n=n.slice(0,Y));var Q=n.indexOf("?");if(-1!==Q?(this.search=n.substr(Q),this.query=n.substr(Q+1),e&&(this.query=R.parse(this.query)),n=n.slice(0,Q)):e&&(this.search="",this.query={}),n&&(this.pathname=n),A[a]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var N=this.pathname||"",_=this.search||"";this.path=N+_}return this.href=this.format(),this},n.prototype.format=function(){var t=this.auth||"";t&&(t=encodeURIComponent(t),t=t.replace(/%3A/i,":"),t+="@");var e=this.protocol||"",r=this.pathname||"",n=this.hash||"",o=!1,a="";this.host?o=t+this.host:this.hostname&&(o=t+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(o+=":"+this.port)),this.query&&l(this.query)&&Object.keys(this.query).length&&(a=R.stringify(this.query));var s=this.search||a&&"?"+a||"";return e&&":"!==e.substr(-1)&&(e+=":"),this.slashes||(!e||A[e])&&o!==!1?(o="//"+(o||""),r&&"/"!==r.charAt(0)&&(r="/"+r)):o||(o=""),n&&"#"!==n.charAt(0)&&(n="#"+n),s&&"?"!==s.charAt(0)&&(s="?"+s),r=r.replace(/[?#]/g,function(t){return encodeURIComponent(t)}),s=s.replace("#","%23"),e+o+r+s+n},n.prototype.resolve=function(t){return this.resolveObject(o(t,!1,!0)).format()},n.prototype.resolveObject=function(t){if(h(t)){var e=new n;e.parse(t,!1,!0),t=e}var r=new n;if(Object.keys(this).forEach(function(t){r[t]=this[t]},this),r.hash=t.hash,""===t.href)return r.href=r.format(),r;if(t.slashes&&!t.protocol)return Object.keys(t).forEach(function(e){"protocol"!==e&&(r[e]=t[e])}),A[r.protocol]&&r.hostname&&!r.pathname&&(r.path=r.pathname="/"),r.href=r.format(),r;if(t.protocol&&t.protocol!==r.protocol){if(!A[t.protocol])return Object.keys(t).forEach(function(e){r[e]=t[e]}),r.href=r.format(),r;if(r.protocol=t.protocol,t.host||I[t.protocol])r.pathname=t.pathname;else{for(var o=(t.pathname||"").split("/");o.length&&!(t.host=o.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),""!==o[0]&&o.unshift(""),o.length<2&&o.unshift(""),r.pathname=o.join("/")}if(r.search=t.search,r.query=t.query,r.host=t.host||"",r.auth=t.auth,r.hostname=t.hostname||t.host,r.port=t.port,r.pathname||r.search){var a=r.pathname||"",s=r.search||"";r.path=a+s}return r.slashes=r.slashes||t.slashes,r.href=r.format(),r}var i=r.pathname&&"/"===r.pathname.charAt(0),l=t.host||t.pathname&&"/"===t.pathname.charAt(0),f=l||i||r.host&&t.pathname,p=f,y=r.pathname&&r.pathname.split("/")||[],o=t.pathname&&t.pathname.split("/")||[],d=r.protocol&&!A[r.protocol];if(d&&(r.hostname="",r.port=null,r.host&&(""===y[0]?y[0]=r.host:y.unshift(r.host)),r.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(""===o[0]?o[0]=t.host:o.unshift(t.host)),t.host=null),f=f&&(""===o[0]||""===y[0])),l)r.host=t.host||""===t.host?t.host:r.host,r.hostname=t.hostname||""===t.hostname?t.hostname:r.hostname,r.search=t.search,r.query=t.query,y=o;else if(o.length)y||(y=[]),y.pop(),y=y.concat(o),r.search=t.search,r.query=t.query;else if(!c(t.search)){if(d){r.hostname=r.host=y.shift();var m=r.host&&r.host.indexOf("@")>0?r.host.split("@"):!1;m&&(r.auth=m.shift(),r.host=r.hostname=m.shift())}return r.search=t.search,r.query=t.query,u(r.pathname)&&u(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!y.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var x=y.slice(-1)[0],v=(r.host||t.host)&&("."===x||".."===x)||""===x,g=0,O=y.length;O>=0;O--)x=y[O],"."==x?y.splice(O,1):".."===x?(y.splice(O,1),g++):g&&(y.splice(O,1),g--);if(!f&&!p)for(;g--;g)y.unshift("..");!f||""===y[0]||y[0]&&"/"===y[0].charAt(0)||y.unshift(""),v&&"/"!==y.join("/").substr(-1)&&y.push("");var E=""===y[0]||y[0]&&"/"===y[0].charAt(0);if(d){r.hostname=r.host=E?"":y.length?y.shift():"";var m=r.host&&r.host.indexOf("@")>0?r.host.split("@"):!1;m&&(r.auth=m.shift(),r.host=r.hostname=m.shift())}return f=f||r.host&&y.length,f&&!E&&y.unshift(""),y.length?r.pathname=y.join("/"):(r.pathname=null,r.path=null),u(r.pathname)&&u(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},n.prototype.parseHost=function(){var t=this.host,e=y.exec(t);e&&(e=e[0],":"!==e&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},{punycode:2,querystring:5}],7:[function(t,e,r){"use strict";function n(t){if(null===t||void 0===t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}var o=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable;e.exports=Object.assign||function(t,e){for(var r,s,i=n(t),h=1;ha&&e===!1)return!0;if(1>s&&n===!1)return!0;if(e!==n)return!1;if(a!==s)return!1;for(o=0;a>o;o++)if(t[o]!==r[o])return!1;return!0}e.exports=n},{}],12:[function(t,e,r){"use strict";function n(t,e){var r,n,o,a,s,i,h,l=0;for(r in t){if(a=t.hasOwnProperty(r),i=e.hasOwnProperty(r),a===!1||i===!1||a!==i)return!1;if(a=t[r],i=e[r],a!==i){if(Array.isArray(a)===!1||Array.isArray(i)===!1)return!1;if(o=a.length,o!==i.length)return!1;for(s=a.slice().sort(),h=i.slice().sort(),n=0;o>n;n++)if(s[n]!==h[n])return!1}l++}return l!==Object.keys(e).length?!1:!0}e.exports=n},{}],13:[function(t,e,r){"use strict";function n(t){var e=t.pathname;return null!==t.search&&(e+=t.search),e}e.exports=n},{}],14:[function(t,e,r){"use strict";function n(t){var e=o(t.extra.directory,t.extra.directoryLeadingSlash);return null!==t.extra.filename&&(e+=t.extra.filename),e}var o=t("./joinDirs");e.exports=n},{"./joinDirs":18}],15:[function(t,e,r){"use strict";e.exports={format:t("url").format,normalize:t("./normalizeUrl"),parse:t("./parseUrl"),relation:t("./urlRelation"),resolve:t("./resolveUrl"),component:t("./UrlComponent"),type:t("./UrlType"),areSameDir:t("./areSameDir"),areSameQuery:t("./areSameQuery"),joinDirs:t("./joinDirs"),joinQuery:t("./joinQuery"),normalizeDirs:t("./normalizeDirs"),parsePath:t("./parsePath"),resolveDirs:t("./resolveDirs"),typeofUrl:t("./typeofUrl")}},{"./UrlComponent":9,"./UrlType":10,"./areSameDir":11,"./areSameQuery":12,"./joinDirs":18,"./joinQuery":19,"./normalizeDirs":20,"./normalizeUrl":21,"./parsePath":22,"./parseUrl":23,"./resolveDirs":24,"./resolveUrl":25,"./typeofUrl":26,"./urlRelation":27,url:6}],16:[function(t,e,r){"use strict";function n(t){return a(t)===!0?s.STRING:o(t)===!0&&Array.isArray(t)===!1&&void 0!==t.protocol?o(t.extra)===!0?s.URLOBJ:s.CORE_URL_OBJECT:s.OTHER}var o=t("is-object"),a=t("is-string"),s=t("./InputTypes");e.exports=n},{"./InputTypes":8,"is-object":28,"is-string":29}],17:[function(t,e,r){"use strict";function n(t,e,r){return null!==t?null===e?!0:(o(r)===!1&&(r=a),r[t]===parseInt(e)):null}var o=t("is-object"),a={ftp:21,gopher:70,http:80,https:443};e.exports=n},{"is-object":28}],18:[function(t,e,r){"use strict";function n(t,e){var r,n=t.length,o=e===!0?"/":"";for(r=0;n>r;r++)""!==t[r]&&(o+=t[r]+"/");return o}e.exports=n},{}],19:[function(t,e,r){"use strict";function n(t,e){var r,n,a,s,i={i:0},h="";for(s in t)if(t.hasOwnProperty(s)===!0)if(a=t[s],Array.isArray(a)===!1)h+=o(s,a,i,e);else for(n=a.length,r=0;n>r;r++)h+=o(s,a[r],i,e);return h}function o(t,e,r,n){var o="";return(""!==t&&""!==e||n!==!0)&&(o+=++r.i>1?"&":"?",t=encodeURIComponent(t),o+=""!==e?t+"="+encodeURIComponent(e).replace(/%20/g,"+"):t+"="),o}e.exports=n},{}],20:[function(t,e,r){"use strict";function n(t,e){var r,n,o,a=t.length,s={dir:[],leadingSlash:e===!0};for(n=0;a>n;n++)r=t[n],".."!==r?"."!==r&&s.dir.push(r):(o=s.dir.length>0?s.dir[s.dir.length-1]:null,null!==o&&(s.leadingSlash===!0||".."!==o&&"."!==o)?s.dir.splice(s.dir.length-1,1):s.leadingSlash===!1&&s.dir.push(r));return s}e.exports=n},{}],21:[function(t,e,r){"use strict";function n(t,e){var r;return t=l(t,e),t.extra.portIsDefault===!0&&null!==t.port&&(o(t.host)===!0&&(r=":"+t.port,t.host.substr(-r.length)===r&&(t.host=t.host.slice(0,-r.length))),t.port=null),t.extra.directory=h(t.extra.directory,t.extra.directoryLeadingSlash).dir,t.pathname=i(t),"?"===t.search&&(t.search=null,("?"===t.query||""===t.query)&&(t.query=null)),t.path=s(t),t.href=a.format(t),t}var o=t("is-string"),a=t("url"),s=t("./formatPath"),i=t("./formatPathname"),h=t("./normalizeDirs"),l=t("./parseUrl");e.exports=n},{"./formatPath":13,"./formatPathname":14,"./normalizeDirs":20,"./parseUrl":23,"is-string":29,url:6}],22:[function(t,e,r){"use strict";function n(t){var e,r,n={dir:[],filename:null,leadingSlash:!1};return a(t)===!0&&t.length>0&&(r=t.lastIndexOf("/"),r>-1?(++rr;r++)""!==e[r]&&o.push(e[r]);return o}var a=t("is-string");e.exports=n},{"is-string":29}],23:[function(t,e,r){"use strict";function n(t,e){return null===t?!0:(Array.isArray(e)===!1&&(e=y),e.indexOf(t)>-1)}function o(t,e){var r={};return r=c(t)===!0?t:{parseQueryString:t,slashesDenoteHost:e}}function a(t,e,r){var a,c=o(e,r),y=s(t);switch(y){case i.STRING:t=p.parse(t,!0,c.slashesDenoteHost);break;case i.CORE_URL_OBJECT:(null==t.search&&null==t.query||f(t.search)===!0&&f(t.query)===!0)&&(t=p.parse(t.href,!0,c.slashesDenoteHost));break;case i.URLOBJ:return t;default:throw new Error("invalid input type")}return a=l(t.pathname),t.extra={},f(t.protocol)===!0?":"===t.protocol[t.protocol.length-1]&&(t.extra.protocolTruncated=t.protocol.substr(0,t.protocol.length-1)):t.extra.protocolTruncated=null,t.extra.portIsDefault=h(t.extra.protocolTruncated,t.port,c.defaultPorts),t.extra.directory=a.dir,t.extra.directoryLeadingSlash=a.leadingSlash,t.extra.filename=a.filename,t.extra.filenameIsIndex=n(a.filename,c.directoryIndexes),t.extra.query=t.query,c.parseQueryString!==!0&&(""!==t.search?"?"===t.search[0]?t.query=t.search.substr(1):t.query=t.search:(t.search=null,t.query=null)),t.extra.type=u(t),t}var s=t("./inputType"),i=t("./InputTypes"),h=t("./isDefaultPort"),l=t("./parsePath"),u=t("./typeofUrl"),c=(t("./UrlType"),t("is-object")),f=t("is-string"),p=t("url"),y=["index.html"];e.exports=a},{"./InputTypes":8,"./UrlType":10,"./inputType":16,"./isDefaultPort":17,"./parsePath":22,"./typeofUrl":26,"is-object":28,"is-string":29,url:6}],24:[function(t,e,r){"use strict";function n(t,e,r,n){var a={dir:null,leadingSlash:!1};return n===!0?(a.dir=r.slice(),a.leadingSlash=n):(a.dir=t.concat(r),a.leadingSlash=e===!0),a.dir=o(a.dir,a.leadingSlash).dir,a}var o=t("./normalizeDirs");e.exports=n},{"./normalizeDirs":20}],25:[function(t,e,r){"use strict";function n(t,e){return e.extra.type>=O.FILENAME_RELATIVE?(e.extra.directory=t.extra.directory.slice(),e.extra.directoryLeadingSlash=t.extra.directoryLeadingSlash,!0):!1}function o(t,e){return e.extra.type>=O.QUERY_RELATIVE?(e.extra.filename=t.extra.filename,e.extra.filenameIsIndex=t.extra.filenameIsIndex,!0):!1}function a(t,e){return e.extra.type>=O.ROOT_RELATIVE?(e.auth=t.auth,e.host=t.host,e.port=t.port,e.hostname=t.hostname,e.extra.portIsDefault=t.extra.portIsDefault,!0):!1}function s(t,e){return e.extra.type>=O.PROTOCOL_RELATIVE?(e.protocol=t.protocol,e.slashes=t.slashes,e.extra.protocolTruncated=t.extra.protocolTruncated,!0):!1}function i(t,e){return e.extra.type>=O.EMPTY?(e.search=t.search,E(t.query)===!0?(e.query=T({},t.query),e.extra.query=e.query):(e.query=t.query,e.extra.query=T({},t.extra.query)),!0):!1}function h(t,e){var r;return t.extra.directory=y(t.extra.directory,t.extra.directoryLeadingSlash).dir,e.extra.directory=y(e.extra.directory,e.extra.directoryLeadingSlash).dir,r=m(t.extra.directory,t.extra.directoryLeadingSlash,e.extra.directory,e.extra.directoryLeadingSlash),e.extra.directory=r.dir,e.extra.directoryLeadingSlash=r.leadingSlash,!0}function l(t,e,r){var l,y,m=!1,E=!1,A=!1,R=!1,U=!1;return r=T({},I,r),t=d(t,r),e=d(e,r),y=g(t,e),y=v.DIRECTORY||l===!0)&&(E=o(t,e),U=i(t,e)),(m===!0||E===!0)&&(e.pathname=f(e)),(m===!0||E===!0||U===!0)&&(e.path=c(e)),R===!0&&A===!1&&(e.extra.portIsDefault=p(e.protocol,e.port,r.defaultPorts)),(R===!0||A===!0||m===!0||E===!0||U===!0)&&(e.href=b.format(e),e.extra.type=x(e)),e)}var u=t("./areSameDir"),c=t("./formatPath"),f=t("./formatPathname"),p=t("./isDefaultPort"),y=t("./normalizeDirs"),d=t("./parseUrl"),m=t("./resolveDirs"),x=t("./typeofUrl"),v=t("./UrlComponent"),g=t("./urlRelation"),O=t("./UrlType"),E=t("is-object"),T=t("object-assign"),b=t("url"),I={slashesDenoteHost:!0};e.exports=l},{"./UrlComponent":9,"./UrlType":10,"./areSameDir":11,"./formatPath":13,"./formatPathname":14,"./isDefaultPort":17,"./normalizeDirs":20,"./parseUrl":23,"./resolveDirs":24,"./typeofUrl":26,"./urlRelation":27,"is-object":28,"object-assign":7,url:6}],26:[function(t,e,r){"use strict";function n(t){return null!==t.protocol?o.ABSOLUTE:null!==t.hostname?o.PROTOCOL_RELATIVE:t.extra.directoryLeadingSlash===!0?o.ROOT_RELATIVE:t.extra.directory.length>0?o.DIRECTORY_RELATIVE:null!==t.extra.filename?o.FILENAME_RELATIVE:null!==t.search?o.QUERY_RELATIVE:null===t.hash?o.EMPTY:o.HASH_RELATIVE}var o=t("./UrlType");e.exports=n},{"./UrlType":10}],27:[function(t,e,r){"use strict";function n(t,e){var r;if(t=i(t),e=i(e),t.extra.type1&&(n=r[0]+"@",t=r[1]),t=t.replace(w,".");var o=t.split("."),s=a(o,e).join(".");return n+s}function h(t){for(var e,r,n=[],o=0,s=t.length;s>o;)e=t.charCodeAt(o++),e>=55296&&56319>=e&&s>o?(r=t.charCodeAt(o++),56320==(64512&r)?n.push(((1023&e)<<10)+(1023&r)+65536):(n.push(e),o--)):n.push(e);return n}function l(t){return a(t,function(t){var e="";return t>65535&&(t-=65536,e+=N(t>>>10&1023|55296),t=56320|1023&t),e+=N(t)}).join("")}function u(t){return 10>t-48?t-22:26>t-65?t-65:26>t-97?t-97:E}function c(t,e){return t+22+75*(26>t)-((0!=e)<<5)}function f(t,e,r){var n=0;for(t=r?H(t/j):t>>1,t+=H(t/e);t>P*S>>1;n+=E)t=H(t/P);return H(n+(P+1)*t/(t+U))}function p(t){var e,r,n,o,a,i,h,c,p,y,d=[],m=t.length,x=0,v=R,g=A;for(r=t.lastIndexOf(L),0>r&&(r=0),n=0;r>n;++n)t.charCodeAt(n)>=128&&s("not-basic"),d.push(t.charCodeAt(n));for(o=r>0?r+1:0;m>o;){for(a=x,i=1,h=E;o>=m&&s("invalid-input"),c=u(t.charCodeAt(o++)),(c>=E||c>H((T-x)/i))&&s("overflow"),x+=c*i,p=g>=h?I:h>=g+S?S:h-g,!(p>c);h+=E)y=E-p,i>H(T/y)&&s("overflow"),i*=y;e=d.length+1,g=f(x-a,e,0==a),H(x/e)>T-v&&s("overflow"),v+=H(x/e),x%=e,d.splice(x++,0,v)}return l(d)}function y(t){var e,r,n,o,a,i,l,u,p,y,d,m,x,v,g,O=[];for(t=h(t),m=t.length,e=R,r=0,a=A,i=0;m>i;++i)d=t[i],128>d&&O.push(N(d));for(n=o=O.length,o&&O.push(L);m>n;){for(l=T,i=0;m>i;++i)d=t[i],d>=e&&l>d&&(l=d);for(x=n+1,l-e>H((T-r)/x)&&s("overflow"),r+=(l-e)*x,e=l,i=0;m>i;++i)if(d=t[i],e>d&&++r>T&&s("overflow"),d==e){for(u=r,p=E;y=a>=p?I:p>=a+S?S:p-a,!(y>u);p+=E)g=u-y,v=E-y,O.push(N(c(y+g%v,0))),u=H(g/v);O.push(N(c(u,0))),a=f(r,x,n==o),r=0,++n}++r,++e}return O.join("")}function d(t){return i(t,function(t){return C.test(t)?p(t.slice(4).toLowerCase()):t})}function m(t){return i(t,function(t){return D.test(t)?"xn--"+y(t):t})}var x="object"==typeof n&&n&&!n.nodeType&&n,v="object"==typeof r&&r&&!r.nodeType&&r,g="object"==typeof e&&e;(g.global===g||g.window===g||g.self===g)&&(o=g);var O,b,T=2147483647,E=36,I=1,S=26,U=38,j=700,A=72,R=128,L="-",C=/^xn--/,D=/[^\x20-\x7E]/,w=/[\x2E\u3002\uFF0E\uFF61]/g,q={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},P=E-I,H=Math.floor,N=String.fromCharCode;if(O={version:"1.3.2",ucs2:{decode:h,encode:l},decode:p,encode:y,toASCII:m,toUnicode:d},"function"==typeof t&&"object"==typeof t.amd&&t.amd)t("punycode",function(){return O});else if(x&&v)if(r.exports==x)v.exports=O;else for(b in O)O.hasOwnProperty(b)&&(x[b]=O[b]);else o.punycode=O}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],6:[function(t,e,r){"use strict";function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.exports=function(t,e,r,s){e=e||"&",r=r||"=";var a={};if("string"!=typeof t||0===t.length)return a;var i=/\+/g;t=t.split(e);var h=1e3;s&&"number"==typeof s.maxKeys&&(h=s.maxKeys);var l=t.length;h>0&&l>h&&(l=h);for(var u=0;l>u;++u){var c,f,p,y,d=t[u].replace(i,"%20"),m=d.indexOf(r);m>=0?(c=d.substr(0,m),f=d.substr(m+1)):(c=d,f=""),p=decodeURIComponent(c),y=decodeURIComponent(f),n(a,p)?o(a[p])?a[p].push(y):a[p]=[a[p],y]:a[p]=y}return a};var o=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},{}],7:[function(t,e,r){"use strict";function n(t,e){if(t.map)return t.map(e);for(var r=[],n=0;n",'"',"`"," ","\r","\n"," "],y=["{","}","|","\\","^","`"].concat(p),d=["'"].concat(y),m=["%","/","?",";","#"].concat(d),x=["/","?","#"],v=255,g=/^[+a-z0-9A-Z_-]{0,63}$/,O=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,b={javascript:!0,"javascript:":!0},T={javascript:!0,"javascript:":!0},E={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},I=t("querystring");n.prototype.parse=function(t,e,r){if(!l.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var n=t.indexOf("?"),o=-1!==n&&nA)&&(U=A)}var R,L;L=-1===U?i.lastIndexOf("@"):i.lastIndexOf("@",U),-1!==L&&(R=i.slice(0,L),i=i.slice(L+1),this.auth=decodeURIComponent(R)),U=-1;for(var j=0;jA)&&(U=A)}-1===U&&(U=i.length),this.host=i.slice(0,U),i=i.slice(U),this.parseHost(),this.hostname=this.hostname||"";var C="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!C)for(var D=this.hostname.split(/\./),j=0,w=D.length;w>j;j++){var q=D[j];if(q&&!q.match(g)){for(var P="",H=0,N=q.length;N>H;H++)P+=q.charCodeAt(H)>127?"x":q[H];if(!P.match(g)){var _=D.slice(0,j),z=D.slice(j+1),M=q.match(O);M&&(_.push(M[1]),z.unshift(M[2])),z.length&&(i="/"+z.join(".")+i),this.hostname=_.join(".");break}}}this.hostname.length>v?this.hostname="":this.hostname=this.hostname.toLowerCase(),C||(this.hostname=h.toASCII(this.hostname));var V=this.port?":"+this.port:"",Y=this.hostname||"";this.host=Y+V,this.href+=this.host,C&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==i[0]&&(i="/"+i))}if(!b[y])for(var j=0,w=d.length;w>j;j++){var Q=d[j];if(-1!==i.indexOf(Q)){var F=encodeURIComponent(Q);F===Q&&(F=escape(Q)),i=i.split(Q).join(F)}}var B=i.indexOf("#");-1!==B&&(this.hash=i.substr(B),i=i.slice(0,B));var k=i.indexOf("?");if(-1!==k?(this.search=i.substr(k),this.query=i.substr(k+1),e&&(this.query=I.parse(this.query)),i=i.slice(0,k)):e&&(this.search="",this.query={}),i&&(this.pathname=i),E[y]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var V=this.pathname||"",G=this.search||"";this.path=V+G}return this.href=this.format(),this},n.prototype.format=function(){var t=this.auth||"";t&&(t=encodeURIComponent(t),t=t.replace(/%3A/i,":"),t+="@");var e=this.protocol||"",r=this.pathname||"",n=this.hash||"",o=!1,s="";this.host?o=t+this.host:this.hostname&&(o=t+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(o+=":"+this.port)),this.query&&l.isObject(this.query)&&Object.keys(this.query).length&&(s=I.stringify(this.query));var a=this.search||s&&"?"+s||"";return e&&":"!==e.substr(-1)&&(e+=":"),this.slashes||(!e||E[e])&&o!==!1?(o="//"+(o||""),r&&"/"!==r.charAt(0)&&(r="/"+r)):o||(o=""),n&&"#"!==n.charAt(0)&&(n="#"+n),a&&"?"!==a.charAt(0)&&(a="?"+a),r=r.replace(/[?#]/g,function(t){return encodeURIComponent(t)}),a=a.replace("#","%23"),e+o+r+a+n},n.prototype.resolve=function(t){return this.resolveObject(o(t,!1,!0)).format()},n.prototype.resolveObject=function(t){if(l.isString(t)){var e=new n;e.parse(t,!1,!0),t=e}for(var r=new n,o=Object.keys(this),s=0;s0?r.host.split("@"):!1;S&&(r.auth=S.shift(),r.host=r.hostname=S.shift())}return r.search=t.search,r.query=t.query,l.isNull(r.pathname)&&l.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!b.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var U=b.slice(-1)[0],j=(r.host||t.host||b.length>1)&&("."===U||".."===U)||""===U,A=0,R=b.length;R>=0;R--)U=b[R],"."===U?b.splice(R,1):".."===U?(b.splice(R,1),A++):A&&(b.splice(R,1),A--);if(!g&&!O)for(;A--;A)b.unshift("..");!g||""===b[0]||b[0]&&"/"===b[0].charAt(0)||b.unshift(""),j&&"/"!==b.join("/").substr(-1)&&b.push("");var L=""===b[0]||b[0]&&"/"===b[0].charAt(0);if(I){r.hostname=r.host=L?"":b.length?b.shift():"";var S=r.host&&r.host.indexOf("@")>0?r.host.split("@"):!1;S&&(r.auth=S.shift(),r.host=r.hostname=S.shift())}return g=g||r.host&&b.length,g&&!L&&b.unshift(""),b.length?r.pathname=b.join("/"):(r.pathname=null,r.path=null),l.isNull(r.pathname)&&l.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},n.prototype.parseHost=function(){var t=this.host,e=c.exec(t);e&&(e=e[0],":"!==e&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},{"./util":10,punycode:5,querystring:8}],10:[function(t,e,r){"use strict";e.exports={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}}},{}],11:[function(t,e,r){"use strict";e.exports={OTHER:-1,STRING:0,CORE_URL_OBJECT:1,URLOBJ:2}},{}],12:[function(t,e,r){"use strict";e.exports={NOTHING:-1,PROTOCOL:0,SCHEME:0,HOSTNAME:4,PORT:5,HOST:6,AUTH:7,DIRECTORY:8,FILENAME:9,PATHNAME:10,QUERY:11,SEARCH:11,PATH:12,HASH:13,FRAGMENT:13}},{}],13:[function(t,e,r){"use strict";e.exports={UNKNOWN:-1,ABSOLUTE:0,PROTOCOL_RELATIVE:1,ROOT_RELATIVE:2,DIRECTORY_RELATIVE:3,FILENAME_RELATIVE:4,QUERY_RELATIVE:5,EMPTY:6,HASH_RELATIVE:7}},{}],14:[function(t,e,r){"use strict";function n(t,e,r,n){var o,s=t.length,a=r.length;if(1>s&&e===!1)return!0;if(1>a&&n===!1)return!0;if(e!==n)return!1;if(s!==a)return!1;for(o=0;s>o;o++)if(t[o]!==r[o])return!1;return!0}e.exports=n},{}],15:[function(t,e,r){"use strict";function n(t,e){var r,n,o,s,a,i,h,l=0;for(r in t){if(s=t.hasOwnProperty(r),i=e.hasOwnProperty(r),s===!1||i===!1||s!==i)return!1;if(s=t[r],i=e[r],s!==i){if(Array.isArray(s)===!1||Array.isArray(i)===!1)return!1;if(o=s.length,o!==i.length)return!1;for(a=s.slice().sort(),h=i.slice().sort(),n=0;o>n;n++)if(a[n]!==h[n])return!1}l++}return l!==Object.keys(e).length?!1:!0}e.exports=n},{}],16:[function(t,e,r){"use strict";function n(t){var e=t.pathname;return null!==t.search&&(e+=t.search),e}e.exports=n},{}],17:[function(t,e,r){"use strict";function n(t){var e=o(t.extra.directory,t.extra.directoryLeadingSlash);return null!==t.extra.filename&&(e+=t.extra.filename),e}var o=t("./joinDirs");e.exports=n},{"./joinDirs":21}],18:[function(t,e,r){"use strict";e.exports={format:t("url").format,normalize:t("./normalizeUrl"),parse:t("./parseUrl"),relation:t("./urlRelation"),resolve:t("./resolveUrl"),component:t("./UrlComponent"),type:t("./UrlType"),areSameDir:t("./areSameDir"),areSameQuery:t("./areSameQuery"),joinDirs:t("./joinDirs"),joinQuery:t("./joinQuery"),normalizeDirs:t("./normalizeDirs"),parsePath:t("./parsePath"),resolveDirs:t("./resolveDirs"),typeofUrl:t("./typeofUrl")}},{"./UrlComponent":12,"./UrlType":13,"./areSameDir":14,"./areSameQuery":15,"./joinDirs":21,"./joinQuery":22,"./normalizeDirs":23,"./normalizeUrl":24,"./parsePath":25,"./parseUrl":26,"./resolveDirs":27,"./resolveUrl":28,"./typeofUrl":29,"./urlRelation":30,url:9}],19:[function(t,e,r){"use strict";function n(t){return s(t)===!0?a.STRING:o(t)===!0&&Array.isArray(t)===!1&&void 0!==t.protocol?o(t.extra)===!0?a.URLOBJ:a.CORE_URL_OBJECT:a.OTHER}var o=t("is-object"),s=t("is-string"),a=t("./InputTypes");e.exports=n},{"./InputTypes":11,"is-object":2,"is-string":3}],20:[function(t,e,r){"use strict";function n(t,e,r){return null!==t?null===e?!0:(o(r)===!1&&(r=s),r[t]===parseInt(e)):null}var o=t("is-object"),s={ftp:21,gopher:70,http:80,https:443};e.exports=n},{"is-object":2}],21:[function(t,e,r){"use strict";function n(t,e){var r,n=t.length,o=e===!0?"/":"";for(r=0;n>r;r++)""!==t[r]&&(o+=t[r]+"/");return o}e.exports=n},{}],22:[function(t,e,r){"use strict";function n(t,e){var r,n,s,a,i={i:0},h="";for(a in t)if(t.hasOwnProperty(a)===!0)if(s=t[a],Array.isArray(s)===!1)h+=o(a,s,i,e);else for(n=s.length,r=0;n>r;r++)h+=o(a,s[r],i,e);return h}function o(t,e,r,n){var o="";return(""!==t&&""!==e||n!==!0)&&(o+=++r.i>1?"&":"?",t=encodeURIComponent(t),o+=""!==e?t+"="+encodeURIComponent(e).replace(/%20/g,"+"):t+"="),o}e.exports=n},{}],23:[function(t,e,r){"use strict";function n(t,e){var r,n,o,s=t.length,a={dir:[],leadingSlash:e===!0};for(n=0;s>n;n++)r=t[n],".."!==r?"."!==r&&a.dir.push(r):(o=a.dir.length>0?a.dir[a.dir.length-1]:null,null!==o&&(a.leadingSlash===!0||".."!==o&&"."!==o)?a.dir.splice(a.dir.length-1,1):a.leadingSlash===!1&&a.dir.push(r));return a}e.exports=n},{}],24:[function(t,e,r){"use strict";function n(t,e){var r;return t=l(t,e),t.extra.portIsDefault===!0&&null!==t.port&&(o(t.host)===!0&&(r=":"+t.port,t.host.substr(-r.length)===r&&(t.host=t.host.slice(0,-r.length))),t.port=null),t.extra.directory=h(t.extra.directory,t.extra.directoryLeadingSlash).dir,t.pathname=i(t),"?"===t.search&&(t.search=null,("?"===t.query||""===t.query)&&(t.query=null)),t.path=a(t),t.href=s.format(t),t}var o=t("is-string"),s=t("url"),a=t("./formatPath"),i=t("./formatPathname"),h=t("./normalizeDirs"),l=t("./parseUrl");e.exports=n},{"./formatPath":16,"./formatPathname":17,"./normalizeDirs":23,"./parseUrl":26,"is-string":3,url:9}],25:[function(t,e,r){"use strict";function n(t){var e,r,n={dir:[],filename:null,leadingSlash:!1};return s(t)===!0&&t.length>0&&(r=t.lastIndexOf("/"),r>-1?(++rr;r++)""!==e[r]&&o.push(e[r]);return o}var s=t("is-string");e.exports=n},{"is-string":3}],26:[function(t,e,r){"use strict";function n(t,e){return null===t?!0:(Array.isArray(e)===!1&&(e=y),e.indexOf(t)>-1)}function o(t,e){var r={};return r=c(t)===!0?t:{parseQueryString:t,slashesDenoteHost:e}}function s(t,e,r){var s,c=o(e,r),y=a(t);switch(y){case i.STRING:t=p.parse(t,!0,c.slashesDenoteHost);break;case i.CORE_URL_OBJECT:(null==t.search&&null==t.query||f(t.search)===!0&&f(t.query)===!0)&&(t=p.parse(t.href,!0,c.slashesDenoteHost));break;case i.URLOBJ:return t;default:throw new Error("invalid input type")}return s=l(t.pathname),t.extra={},f(t.protocol)===!0?":"===t.protocol[t.protocol.length-1]&&(t.extra.protocolTruncated=t.protocol.substr(0,t.protocol.length-1)):t.extra.protocolTruncated=null,t.extra.portIsDefault=h(t.extra.protocolTruncated,t.port,c.defaultPorts),t.extra.directory=s.dir,t.extra.directoryLeadingSlash=s.leadingSlash,t.extra.filename=s.filename,t.extra.filenameIsIndex=n(s.filename,c.directoryIndexes),t.extra.query=t.query,c.parseQueryString!==!0&&(""!==t.search?"?"===t.search[0]?t.query=t.search.substr(1):t.query=t.search:(t.search=null,t.query=null)),t.extra.type=u(t),t}var a=t("./inputType"),i=t("./InputTypes"),h=t("./isDefaultPort"),l=t("./parsePath"),u=t("./typeofUrl"),c=(t("./UrlType"),t("is-object")),f=t("is-string"),p=t("url"),y=["index.html"];e.exports=s},{"./InputTypes":11,"./UrlType":13,"./inputType":19,"./isDefaultPort":20,"./parsePath":25,"./typeofUrl":29,"is-object":2,"is-string":3,url:9}],27:[function(t,e,r){"use strict";function n(t,e,r,n){var s={dir:null,leadingSlash:!1};return n===!0?(s.dir=r.slice(),s.leadingSlash=n):(s.dir=t.concat(r),s.leadingSlash=e===!0),s.dir=o(s.dir,s.leadingSlash).dir,s}var o=t("./normalizeDirs");e.exports=n},{"./normalizeDirs":23}],28:[function(t,e,r){"use strict";function n(t,e){return e.extra.type>=O.FILENAME_RELATIVE?(e.extra.directory=t.extra.directory.slice(),e.extra.directoryLeadingSlash=t.extra.directoryLeadingSlash,!0):!1}function o(t,e){return e.extra.type>=O.QUERY_RELATIVE?(e.extra.filename=t.extra.filename,e.extra.filenameIsIndex=t.extra.filenameIsIndex,!0):!1}function s(t,e){return e.extra.type>=O.ROOT_RELATIVE?(e.auth=t.auth,e.host=t.host,e.port=t.port,e.hostname=t.hostname,e.extra.portIsDefault=t.extra.portIsDefault,!0):!1}function a(t,e){return e.extra.type>=O.PROTOCOL_RELATIVE?(e.protocol=t.protocol,e.slashes=t.slashes,e.extra.protocolTruncated=t.extra.protocolTruncated,!0):!1}function i(t,e){return e.extra.type>=O.EMPTY?(e.search=t.search,b(t.query)===!0?(e.query=T({},t.query),e.extra.query=e.query):(e.query=t.query,e.extra.query=T({},t.extra.query)),!0):!1}function h(t,e){var r;return t.extra.directory=y(t.extra.directory,t.extra.directoryLeadingSlash).dir,e.extra.directory=y(e.extra.directory,e.extra.directoryLeadingSlash).dir,r=m(t.extra.directory,t.extra.directoryLeadingSlash,e.extra.directory,e.extra.directoryLeadingSlash),e.extra.directory=r.dir,e.extra.directoryLeadingSlash=r.leadingSlash,!0}function l(t,e,r){var l,y,m=!1,b=!1,S=!1,U=!1,j=!1;return r=T({},I,r),t=d(t,r),e=d(e,r),y=g(t,e),y=v.DIRECTORY||l===!0)&&(b=o(t,e),j=i(t,e)),(m===!0||b===!0)&&(e.pathname=f(e)),(m===!0||b===!0||j===!0)&&(e.path=c(e)),U===!0&&S===!1&&(e.extra.portIsDefault=p(e.protocol,e.port,r.defaultPorts)),(U===!0||S===!0||m===!0||b===!0||j===!0)&&(e.href=E.format(e),e.extra.type=x(e)),e)}var u=t("./areSameDir"),c=t("./formatPath"),f=t("./formatPathname"),p=t("./isDefaultPort"),y=t("./normalizeDirs"),d=t("./parseUrl"),m=t("./resolveDirs"),x=t("./typeofUrl"),v=t("./UrlComponent"),g=t("./urlRelation"),O=t("./UrlType"),b=t("is-object"),T=t("object-assign"),E=t("url"),I={slashesDenoteHost:!0};e.exports=l},{"./UrlComponent":12,"./UrlType":13,"./areSameDir":14,"./formatPath":16,"./formatPathname":17,"./isDefaultPort":20,"./normalizeDirs":23,"./parseUrl":26,"./resolveDirs":27,"./typeofUrl":29,"./urlRelation":30,"is-object":2,"object-assign":4,url:9}],29:[function(t,e,r){"use strict";function n(t){return null!==t.protocol?o.ABSOLUTE:null!==t.hostname?o.PROTOCOL_RELATIVE:t.extra.directoryLeadingSlash===!0?o.ROOT_RELATIVE:t.extra.directory.length>0?o.DIRECTORY_RELATIVE:null!==t.extra.filename?o.FILENAME_RELATIVE:null!==t.search?o.QUERY_RELATIVE:null===t.hash?o.EMPTY:o.HASH_RELATIVE}var o=t("./UrlType");e.exports=n},{"./UrlType":13}],30:[function(t,e,r){"use strict";function n(t,e){var r;if(t=i(t),e=i(e),t.extra.type= 0.10" + "node": ">= 4" }, "scripts": { "browserify": "browserify index.js --standalone UrlCache | uglifyjs --compress --mangle -o index-browser.js", diff --git a/test.js b/test.js index baf06e3..73e7d49 100644 --- a/test.js +++ b/test.js @@ -2,13 +2,13 @@ var UrlCache = require("./"); var chai = require("chai"); -var objectAssign = require("object-assign"); var urllib = require("url"); var expect = chai.expect; chai.use( require("chai-as-promised") ); require("es6-promise").polyfill(); +require("object.assign").shim(); @@ -22,7 +22,7 @@ function options(overrides) stripUrlHashes: false }; - return objectAssign({}, testDefaults, overrides); + return Object.assign({}, testDefaults, overrides); } @@ -163,6 +163,40 @@ describe("clear()", function() +describe("length()", function() +{ + it("should work", function() + { + var cache = new UrlCache( options() ); + + expect(cache.length()).to.equal(0); + + cache.clear(); + expect(cache.length()).to.equal(0); + + cache.clear("not-available"); + expect(cache.length()).to.equal(0); + + cache.set("some-url1", "some value1"); + expect(cache.length()).to.equal(1); + + cache.set("some-url2", "some value2"); + cache.set("some-url3", "some value3"); + expect(cache.length()).to.equal(3); + + cache.clear("not-available"); + expect(cache.length()).to.equal(3); + + cache.clear("some-url3"); + expect(cache.length()).to.equal(2); + + cache.clear(); + expect(cache.length()).to.equal(0); + }); +}); + + + describe("options", function() { it("expiryTime = 50", function(done)