universal-router
Advanced tools
Comparing version 4.2.0 to 4.2.1
@@ -67,3 +67,3 @@ /*! Universal Router | MIT License | https://www.kriasoft.com/universal-router/ */ | ||
path: !end && path.charAt(path.length - 1) === '/' ? path.substr(1) : path, | ||
keys: regexp.keys.concat(parentKeys), | ||
keys: parentKeys.concat(regexp.keys), | ||
params: params | ||
@@ -70,0 +70,0 @@ }; |
{ | ||
"private": true, | ||
"name": "generateUrls", | ||
"version": "4.2.0", | ||
"version": "4.2.1", | ||
"description": "Universal Router Generate URLs Add-on", | ||
@@ -6,0 +6,0 @@ "homepage": "https://www.kriasoft.com/universal-router/", |
@@ -67,3 +67,3 @@ /*! Universal Router | MIT License | https://www.kriasoft.com/universal-router/ */ | ||
path: !end && path.charAt(path.length - 1) === '/' ? path.substr(1) : path, | ||
keys: regexp.keys.concat(parentKeys), | ||
keys: parentKeys.concat(regexp.keys), | ||
params: params | ||
@@ -70,0 +70,0 @@ }; |
@@ -66,3 +66,3 @@ /*! Universal Router | MIT License | https://www.kriasoft.com/universal-router/ */ | ||
path: !end && path.charAt(path.length - 1) === '/' ? path.substr(1) : path, | ||
keys: regexp.keys.concat(parentKeys), | ||
keys: parentKeys.concat(regexp.keys), | ||
params | ||
@@ -69,0 +69,0 @@ }; |
{ | ||
"name": "universal-router", | ||
"version": "4.2.0", | ||
"version": "4.2.1", | ||
"description": "Isomorphic router for JavaScript web applications", | ||
@@ -5,0 +5,0 @@ "homepage": "https://www.kriasoft.com/universal-router/", |
@@ -24,3 +24,3 @@ <a href="https://www.kriasoft.com/universal-router/" target="_blank"> | ||
✓ It has [simple code](https://github.com/kriasoft/universal-router/blob/v4.2.0/src/UniversalRouter.js) | ||
✓ It has [simple code](https://github.com/kriasoft/universal-router/blob/v4.2.1/src/UniversalRouter.js) | ||
with only single [path-to-regexp](https://github.com/pillarjs/path-to-regexp) dependency<br> | ||
@@ -46,3 +46,3 @@ ✓ It can be used with any JavaScript framework such as React, Vue.js etc<br> | ||
```html | ||
<script src="https://unpkg.com/universal-router@4.2.0/universal-router.min.js"></script> | ||
<script src="https://unpkg.com/universal-router@4.2.1/universal-router.min.js"></script> | ||
``` | ||
@@ -49,0 +49,0 @@ |
@@ -60,3 +60,3 @@ /** | ||
path: !end && path.charAt(path.length - 1) === '/' ? path.substr(1) : path, | ||
keys: regexp.keys.concat(parentKeys), | ||
keys: parentKeys.concat(regexp.keys), | ||
params, | ||
@@ -63,0 +63,0 @@ }; |
@@ -443,3 +443,3 @@ /*! Universal Router | MIT License | https://www.kriasoft.com/universal-router/ */ | ||
path: !end && path.charAt(path.length - 1) === '/' ? path.substr(1) : path, | ||
keys: regexp.keys.concat(parentKeys), | ||
keys: parentKeys.concat(regexp.keys), | ||
params: params | ||
@@ -446,0 +446,0 @@ }; |
/*! Universal Router | MIT License | https://www.kriasoft.com/universal-router/ */ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.UniversalRouter=t()}(this,function(){"use strict";function e(e,t){for(var o,a=[],i=0,u=0,l="",s=t&&t.delimiter||"/",p=t&&t.delimiters||"./",c=!1;null!==(o=b.exec(e));){var f=o[0],h=o[1],v=o.index;if(l+=e.slice(u,v),u=v+f.length,h)l+=h[1],c=!0;else{var d="",g=e[u],m=o[2],y=o[3],x=o[4],w=o[5];if(!c&&l.length){var E=l.length-1;p.indexOf(l[E])>-1&&(d=l[E],l=l.slice(0,E))}l&&(a.push(l),l="",c=!1);var R=""!==d&&void 0!==g&&g!==d,j="+"===w||"*"===w,k="?"===w||"*"===w,O=d||s,T=y||x;a.push({name:m||i++,prefix:d,delimiter:O,optional:k,repeat:j,partial:R,pattern:T?n(T):"[^"+r(O)+"]+?"})}}return(l||u<e.length)&&a.push(l+e.substr(u)),a}function t(e){for(var t=new Array(e.length),r=0;r<e.length;r++)"object"==typeof e[r]&&(t[r]=new RegExp("^(?:"+e[r].pattern+")$"));return function(r,n){for(var o="",a=n&&n.encode||encodeURIComponent,i=0;i<e.length;i++){var u=e[i];if("string"!=typeof u){var l,s=r?r[u.name]:void 0;if(Array.isArray(s)){if(!u.repeat)throw new TypeError('Expected "'+u.name+'" to not repeat, but got array');if(0===s.length){if(u.optional)continue;throw new TypeError('Expected "'+u.name+'" to not be empty')}for(var p=0;p<s.length;p++){if(l=a(s[p]),!t[i].test(l))throw new TypeError('Expected all "'+u.name+'" to match "'+u.pattern+'"');o+=(0===p?u.prefix:u.delimiter)+l}}else if("string"!=typeof s&&"number"!=typeof s&&"boolean"!=typeof s){if(!u.optional)throw new TypeError('Expected "'+u.name+'" to be '+(u.repeat?"an array":"a string"));u.partial&&(o+=u.prefix)}else{if(l=a(String(s)),!t[i].test(l))throw new TypeError('Expected "'+u.name+'" to match "'+u.pattern+'", but got "'+l+'"');o+=u.prefix+l}}else o+=u}return o}}function r(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function n(e){return e.replace(/([=!:$/()])/g,"\\$1")}function o(e){return e&&e.sensitive?"":"i"}function a(e,t){if(!t)return e;var r=e.source.match(/\((?!\?)/g);if(r)for(var n=0;n<r.length;n++)t.push({name:n,prefix:null,delimiter:null,optional:!1,repeat:!1,partial:!1,pattern:null});return e}function i(e,t,r){for(var n=[],a=0;a<e.length;a++)n.push(s(e[a],t,r).source);return new RegExp("(?:"+n.join("|")+")",o(r))}function u(t,r,n){return l(e(t,n),r,n)}function l(e,t,n){for(var a=(n=n||{}).strict,i=!1!==n.end,u=r(n.delimiter||"/"),l=[].concat(n.endsWith||[]).map(r).concat("$").join("|"),s="",p=0;p<e.length;p++){var c=e[p];if("string"==typeof c)s+=r(c);else{var f=r(c.prefix),h="(?:"+c.pattern+")";t&&t.push(c),c.repeat&&(h+="(?:"+f+h+")*"),s+=h=c.optional?c.partial?f+"("+h+")?":"(?:"+f+"("+h+"))?":f+"("+h+")"}}return a||(s+="(?:"+u+"(?="+l+"))?"),s+=i?"$"===l?l:"(?="+l+")":"(?="+u+"|"+l+")",new RegExp("^"+s,o(n))}function s(e,t,r){return e instanceof RegExp?a(e,t):Array.isArray(e)?i(e,t,r):u(e,t,r)}function p(e){try{return decodeURIComponent(e)}catch(t){return e}}function c(e,t,r,n){var o=!e.children,a=(e.path||"")+"|"+o,i=E.get(a);if(!i){var u=[];i={keys:u,pattern:g(e.path||"",u,{end:o})},E.set(a,i)}var l=i.pattern.exec(t);if(!l)return null;for(var s=l[0],c=Object.assign({},n),f=1;f<l.length;f+=1){var h=i.keys[f-1],v=h.name,d=l[f];void 0===d&&w.call(c,v)||(h.repeat?c[v]=d?d.split(h.delimiter).map(p):[]:c[v]=d?p(d):d)}return{path:o||"/"!==s.charAt(s.length-1)?s:s.substr(1),keys:i.keys.concat(r),params:c}}function f(e,t,r,n,o){var a=void 0,i=void 0,u=0;return{next:function(){if(!a&&(a=c(e,r,n,o)))return{done:!1,value:{route:e,baseUrl:t,path:a.path,keys:a.keys,params:a.params}};if(a&&e.children)for(;u<e.children.length;){if(!i){var l=e.children[u];l.parent=e,i=f(l,t+a.path,r.substr(a.path.length),a.keys,a.params)}var s=i.next();if(!s.done)return{done:!1,value:s.value};i=null,u+=1}return{done:!0}}}}function h(e,t){return"function"==typeof e.route.action?e.route.action(e,t):null}function v(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function d(e,t){for(var r=t;r;)if((r=r.parent)===e)return!0;return!1}var g=s,m=e,y=t,x=l,b=new RegExp(["(\\\\.)","(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?"].join("|"),"g");g.parse=m,g.compile=function(r,n){return t(e(r,n))},g.tokensToFunction=y,g.tokensToRegExp=x;var w=Object.prototype.hasOwnProperty,E=new Map,R=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),j=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(v(this,e),Object(t)!==t)throw new TypeError("Invalid routes");this.baseUrl=r.baseUrl||"",this.resolveRoute=r.resolveRoute||h,this.context=Object.assign({router:this},r.context),this.root=Array.isArray(t)?{path:"",children:t,parent:null}:t,this.root.parent=null}return R(e,[{key:"resolve",value:function(e){function t(e){var u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a.value.route;return a=i||n.next(),i=null,e||!a.done&&d(u,a.value.route)?a.done?Promise.reject(Object.assign(new Error("Page not found"),{context:r,status:404,statusCode:404})):Promise.resolve(o(Object.assign({},r,a.value),a.value.params)).then(function(r){return null!==r&&void 0!==r?r:t(e,u)}):(i=a,Promise.resolve(null))}var r=Object.assign({},this.context,"string"==typeof e?{pathname:e}:e),n=f(this.root,this.baseUrl,r.pathname.substr(this.baseUrl.length),[],null),o=this.resolveRoute,a=null,i=null;return r.next=t,t(!0,this.root)}}]),e}();return j.pathToRegexp=g,j.matchPath=c,j.matchRoute=f,j.resolveRoute=h,j}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.UniversalRouter=t()}(this,function(){"use strict";function e(e,t){for(var o,a=[],i=0,u=0,l="",s=t&&t.delimiter||"/",p=t&&t.delimiters||"./",c=!1;null!==(o=b.exec(e));){var f=o[0],h=o[1],v=o.index;if(l+=e.slice(u,v),u=v+f.length,h)l+=h[1],c=!0;else{var d="",g=e[u],m=o[2],y=o[3],x=o[4],w=o[5];if(!c&&l.length){var E=l.length-1;p.indexOf(l[E])>-1&&(d=l[E],l=l.slice(0,E))}l&&(a.push(l),l="",c=!1);var R=""!==d&&void 0!==g&&g!==d,j="+"===w||"*"===w,k="?"===w||"*"===w,O=d||s,T=y||x;a.push({name:m||i++,prefix:d,delimiter:O,optional:k,repeat:j,partial:R,pattern:T?n(T):"[^"+r(O)+"]+?"})}}return(l||u<e.length)&&a.push(l+e.substr(u)),a}function t(e){for(var t=new Array(e.length),r=0;r<e.length;r++)"object"==typeof e[r]&&(t[r]=new RegExp("^(?:"+e[r].pattern+")$"));return function(r,n){for(var o="",a=n&&n.encode||encodeURIComponent,i=0;i<e.length;i++){var u=e[i];if("string"!=typeof u){var l,s=r?r[u.name]:void 0;if(Array.isArray(s)){if(!u.repeat)throw new TypeError('Expected "'+u.name+'" to not repeat, but got array');if(0===s.length){if(u.optional)continue;throw new TypeError('Expected "'+u.name+'" to not be empty')}for(var p=0;p<s.length;p++){if(l=a(s[p]),!t[i].test(l))throw new TypeError('Expected all "'+u.name+'" to match "'+u.pattern+'"');o+=(0===p?u.prefix:u.delimiter)+l}}else if("string"!=typeof s&&"number"!=typeof s&&"boolean"!=typeof s){if(!u.optional)throw new TypeError('Expected "'+u.name+'" to be '+(u.repeat?"an array":"a string"));u.partial&&(o+=u.prefix)}else{if(l=a(String(s)),!t[i].test(l))throw new TypeError('Expected "'+u.name+'" to match "'+u.pattern+'", but got "'+l+'"');o+=u.prefix+l}}else o+=u}return o}}function r(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function n(e){return e.replace(/([=!:$/()])/g,"\\$1")}function o(e){return e&&e.sensitive?"":"i"}function a(e,t){if(!t)return e;var r=e.source.match(/\((?!\?)/g);if(r)for(var n=0;n<r.length;n++)t.push({name:n,prefix:null,delimiter:null,optional:!1,repeat:!1,partial:!1,pattern:null});return e}function i(e,t,r){for(var n=[],a=0;a<e.length;a++)n.push(s(e[a],t,r).source);return new RegExp("(?:"+n.join("|")+")",o(r))}function u(t,r,n){return l(e(t,n),r,n)}function l(e,t,n){for(var a=(n=n||{}).strict,i=!1!==n.end,u=r(n.delimiter||"/"),l=[].concat(n.endsWith||[]).map(r).concat("$").join("|"),s="",p=0;p<e.length;p++){var c=e[p];if("string"==typeof c)s+=r(c);else{var f=r(c.prefix),h="(?:"+c.pattern+")";t&&t.push(c),c.repeat&&(h+="(?:"+f+h+")*"),s+=h=c.optional?c.partial?f+"("+h+")?":"(?:"+f+"("+h+"))?":f+"("+h+")"}}return a||(s+="(?:"+u+"(?="+l+"))?"),s+=i?"$"===l?l:"(?="+l+")":"(?="+u+"|"+l+")",new RegExp("^"+s,o(n))}function s(e,t,r){return e instanceof RegExp?a(e,t):Array.isArray(e)?i(e,t,r):u(e,t,r)}function p(e){try{return decodeURIComponent(e)}catch(t){return e}}function c(e,t,r,n){var o=!e.children,a=(e.path||"")+"|"+o,i=E.get(a);if(!i){var u=[];i={keys:u,pattern:g(e.path||"",u,{end:o})},E.set(a,i)}var l=i.pattern.exec(t);if(!l)return null;for(var s=l[0],c=Object.assign({},n),f=1;f<l.length;f+=1){var h=i.keys[f-1],v=h.name,d=l[f];void 0===d&&w.call(c,v)||(h.repeat?c[v]=d?d.split(h.delimiter).map(p):[]:c[v]=d?p(d):d)}return{path:o||"/"!==s.charAt(s.length-1)?s:s.substr(1),keys:r.concat(i.keys),params:c}}function f(e,t,r,n,o){var a=void 0,i=void 0,u=0;return{next:function(){if(!a&&(a=c(e,r,n,o)))return{done:!1,value:{route:e,baseUrl:t,path:a.path,keys:a.keys,params:a.params}};if(a&&e.children)for(;u<e.children.length;){if(!i){var l=e.children[u];l.parent=e,i=f(l,t+a.path,r.substr(a.path.length),a.keys,a.params)}var s=i.next();if(!s.done)return{done:!1,value:s.value};i=null,u+=1}return{done:!0}}}}function h(e,t){return"function"==typeof e.route.action?e.route.action(e,t):null}function v(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function d(e,t){for(var r=t;r;)if((r=r.parent)===e)return!0;return!1}var g=s,m=e,y=t,x=l,b=new RegExp(["(\\\\.)","(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?"].join("|"),"g");g.parse=m,g.compile=function(r,n){return t(e(r,n))},g.tokensToFunction=y,g.tokensToRegExp=x;var w=Object.prototype.hasOwnProperty,E=new Map,R=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),j=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(v(this,e),Object(t)!==t)throw new TypeError("Invalid routes");this.baseUrl=r.baseUrl||"",this.resolveRoute=r.resolveRoute||h,this.context=Object.assign({router:this},r.context),this.root=Array.isArray(t)?{path:"",children:t,parent:null}:t,this.root.parent=null}return R(e,[{key:"resolve",value:function(e){function t(e){var u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a.value.route;return a=i||n.next(),i=null,e||!a.done&&d(u,a.value.route)?a.done?Promise.reject(Object.assign(new Error("Page not found"),{context:r,status:404,statusCode:404})):Promise.resolve(o(Object.assign({},r,a.value),a.value.params)).then(function(r){return null!==r&&void 0!==r?r:t(e,u)}):(i=a,Promise.resolve(null))}var r=Object.assign({},this.context,"string"==typeof e?{pathname:e}:e),n=f(this.root,this.baseUrl,r.pathname.substr(this.baseUrl.length),[],null),o=this.resolveRoute,a=null,i=null;return r.next=t,t(!0,this.root)}}]),e}();return j.pathToRegexp=g,j.matchPath=c,j.matchRoute=f,j.resolveRoute=h,j}); | ||
//# sourceMappingURL=universal-router.min.js.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
251099