Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

universal-router

Package Overview
Dependencies
Maintainers
2
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

universal-router - npm Package Compare versions

Comparing version 5.0.0 to 5.1.0

12

generateUrls/browser.js

@@ -25,3 +25,3 @@ /*! Universal Router | MIT License | https://www.kriasoft.com/universal-router/ */

function cacheRoutes(routesByName, route, routes) {
if (routesByName[route.name]) {
if (routesByName.has(route.name)) {
throw new Error('Route "' + route.name + '" already exists');

@@ -31,3 +31,3 @@ }

if (route.name) {
routesByName[route.name] = route;
routesByName.set(route.name, route);
}

@@ -51,11 +51,11 @@

router.routesByName = router.routesByName || {};
router.routesByName = router.routesByName || new Map();
return function (routeName, params) {
var route = router.routesByName[routeName];
var route = router.routesByName.get(routeName);
if (!route) {
router.routesByName = {}; // clear cache
router.routesByName.clear(); // clear cache
cacheRoutes(router.routesByName, router.root, router.root.children);
route = router.routesByName[routeName];
route = router.routesByName.get(routeName);
if (!route) {

@@ -62,0 +62,0 @@ throw new Error('Route "' + routeName + '" not found');

@@ -25,3 +25,3 @@ /*! Universal Router | MIT License | https://www.kriasoft.com/universal-router/ */

function cacheRoutes(routesByName, route, routes) {
if (routesByName[route.name]) {
if (routesByName.has(route.name)) {
throw new Error('Route "' + route.name + '" already exists');

@@ -31,3 +31,3 @@ }

if (route.name) {
routesByName[route.name] = route;
routesByName.set(route.name, route);
}

@@ -51,11 +51,11 @@

router.routesByName = router.routesByName || {};
router.routesByName = router.routesByName || new Map();
return function (routeName, params) {
var route = router.routesByName[routeName];
var route = router.routesByName.get(routeName);
if (!route) {
router.routesByName = {}; // clear cache
router.routesByName.clear(); // clear cache
cacheRoutes(router.routesByName, router.root, router.root.children);
route = router.routesByName[routeName];
route = router.routesByName.get(routeName);
if (!route) {

@@ -62,0 +62,0 @@ throw new Error('Route "' + routeName + '" not found');

@@ -24,3 +24,3 @@ /*! Universal Router | MIT License | https://www.kriasoft.com/universal-router/ */

function cacheRoutes(routesByName, route, routes) {
if (routesByName[route.name]) {
if (routesByName.has(route.name)) {
throw new Error(`Route "${route.name}" already exists`);

@@ -30,3 +30,3 @@ }

if (route.name) {
routesByName[route.name] = route;
routesByName.set(route.name, route);
}

@@ -48,11 +48,11 @@

router.routesByName = router.routesByName || {};
router.routesByName = router.routesByName || new Map();
return (routeName, params) => {
let route = router.routesByName[routeName];
let route = router.routesByName.get(routeName);
if (!route) {
router.routesByName = {}; // clear cache
router.routesByName.clear(); // clear cache
cacheRoutes(router.routesByName, router.root, router.root.children);
route = router.routesByName[routeName];
route = router.routesByName.get(routeName);
if (!route) {

@@ -59,0 +59,0 @@ throw new Error(`Route "${routeName}" not found`);

{
"private": true,
"name": "generateUrls",
"version": "5.0.0",
"version": "5.1.0",
"description": "Universal Router Generate URLs Add-on",

@@ -6,0 +6,0 @@ "homepage": "https://www.kriasoft.com/universal-router/",

{
"name": "universal-router",
"version": "5.0.0",
"version": "5.1.0",
"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/v5.0.0/src/UniversalRouter.js)
✓ It has [simple code](https://github.com/kriasoft/universal-router/blob/v5.1.0/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@5.0.0/universal-router.min.js"></script>
<script src="https://unpkg.com/universal-router@5.1.0/universal-router.min.js"></script>
```

@@ -120,2 +120,4 @@

by [Michael Sargent](https://twitter.com/michaelksarge)<br>
:page_facing_up: &nbsp; **[Getting Started with Relay “Modern” for Building Isomorphic Web Apps](https://hackernoon.com/ae049e4e23c1)**
by [Konstantin Tarkus](https://twitter.com/koistya)<br>

@@ -125,35 +127,34 @@

Does your company use Universal Router in production? Please consider
[sponsoring this project](https://opencollective.com/universal-router#sponsor).
Your help will allow maintainers to dedicate more time and resources to its development and support.
Become a sponsor and get your logo on our README on Github with a link to your site.
[[Become a sponsor](https://opencollective.com/universal-router#sponsor)]
<a href="https://opencollective.com/universal-router/sponsor/0/website" target="_blank">
<img src="https://opencollective.com/universal-router/sponsor/0/avatar.svg" height="64">
<img src="https://opencollective.com/universal-router/sponsor/0/avatar.svg?2018-01-16" height="64">
</a>
<a href="https://opencollective.com/universal-router/sponsor/1/website" target="_blank">
<img src="https://opencollective.com/universal-router/sponsor/1/avatar.svg">
<img src="https://opencollective.com/universal-router/sponsor/1/avatar.svg?2018-01-16">
</a>
<a href="https://opencollective.com/universal-router/sponsor/2/website" target="_blank">
<img src="https://opencollective.com/universal-router/sponsor/2/avatar.svg">
<img src="https://opencollective.com/universal-router/sponsor/2/avatar.svg?2018-01-16">
</a>
<a href="https://opencollective.com/universal-router/sponsor/3/website" target="_blank">
<img src="https://opencollective.com/universal-router/sponsor/3/avatar.svg">
<img src="https://opencollective.com/universal-router/sponsor/3/avatar.svg?2018-01-16">
</a>
<a href="https://opencollective.com/universal-router/sponsor/4/website" target="_blank">
<img src="https://opencollective.com/universal-router/sponsor/4/avatar.svg">
<img src="https://opencollective.com/universal-router/sponsor/4/avatar.svg?2018-01-16">
</a>
<a href="https://opencollective.com/universal-router/sponsor/5/website" target="_blank">
<img src="https://opencollective.com/universal-router/sponsor/5/avatar.svg">
<img src="https://opencollective.com/universal-router/sponsor/5/avatar.svg?2018-01-16">
</a>
<a href="https://opencollective.com/universal-router/sponsor/6/website" target="_blank">
<img src="https://opencollective.com/universal-router/sponsor/6/avatar.svg">
<img src="https://opencollective.com/universal-router/sponsor/6/avatar.svg?2018-01-16">
</a>
<a href="https://opencollective.com/universal-router/sponsor/7/website" target="_blank">
<img src="https://opencollective.com/universal-router/sponsor/7/avatar.svg">
<img src="https://opencollective.com/universal-router/sponsor/7/avatar.svg?2018-01-16">
</a>
<a href="https://opencollective.com/universal-router/sponsor/8/website" target="_blank">
<img src="https://opencollective.com/universal-router/sponsor/8/avatar.svg">
<img src="https://opencollective.com/universal-router/sponsor/8/avatar.svg?2018-01-16">
</a>
<a href="https://opencollective.com/universal-router/sponsor/9/website" target="_blank">
<img src="https://opencollective.com/universal-router/sponsor/9/avatar.svg">
<img src="https://opencollective.com/universal-router/sponsor/9/avatar.svg?2018-01-16">
</a>

@@ -164,38 +165,52 @@

♥ Universal Router? [Become a backer](https://opencollective.com/universal-router#backer)
to show your support and help us maintain and improve this open source project.
Get your image on our README with a link to your site.
Support us with a monthly donation and help us continue our activities.
[[Become a backer](https://opencollective.com/universal-router#backer)]
<a href="https://opencollective.com/universal-router/backer/0/website" target="_blank">
<img src="https://opencollective.com/universal-router/backer/0/avatar.svg" height="64">
<img src="https://opencollective.com/universal-router/backer/0/avatar.svg?2018-01-16" height="64">
</a>
<a href="https://opencollective.com/universal-router/backer/1/website" target="_blank">
<img src="https://opencollective.com/universal-router/backer/1/avatar.svg">
<img src="https://opencollective.com/universal-router/backer/1/avatar.svg?2018-01-16">
</a>
<a href="https://opencollective.com/universal-router/backer/2/website" target="_blank">
<img src="https://opencollective.com/universal-router/backer/2/avatar.svg">
<img src="https://opencollective.com/universal-router/backer/2/avatar.svg?2018-01-16">
</a>
<a href="https://opencollective.com/universal-router/backer/3/website" target="_blank">
<img src="https://opencollective.com/universal-router/backer/3/avatar.svg">
<img src="https://opencollective.com/universal-router/backer/3/avatar.svg?2018-01-16">
</a>
<a href="https://opencollective.com/universal-router/backer/4/website" target="_blank">
<img src="https://opencollective.com/universal-router/backer/4/avatar.svg">
<img src="https://opencollective.com/universal-router/backer/4/avatar.svg?2018-01-16">
</a>
<a href="https://opencollective.com/universal-router/backer/5/website" target="_blank">
<img src="https://opencollective.com/universal-router/backer/5/avatar.svg">
<img src="https://opencollective.com/universal-router/backer/5/avatar.svg?2018-01-16">
</a>
<a href="https://opencollective.com/universal-router/backer/6/website" target="_blank">
<img src="https://opencollective.com/universal-router/backer/6/avatar.svg">
<img src="https://opencollective.com/universal-router/backer/6/avatar.svg?2018-01-16">
</a>
<a href="https://opencollective.com/universal-router/backer/7/website" target="_blank">
<img src="https://opencollective.com/universal-router/backer/7/avatar.svg">
<img src="https://opencollective.com/universal-router/backer/7/avatar.svg?2018-01-16">
</a>
<a href="https://opencollective.com/universal-router/backer/8/website" target="_blank">
<img src="https://opencollective.com/universal-router/backer/8/avatar.svg">
<img src="https://opencollective.com/universal-router/backer/8/avatar.svg?2018-01-16">
</a>
<a href="https://opencollective.com/universal-router/backer/9/website" target="_blank">
<img src="https://opencollective.com/universal-router/backer/9/avatar.svg">
<img src="https://opencollective.com/universal-router/backer/9/avatar.svg?2018-01-16">
</a>
## What users say about Universal Router
> Just switched a project over to universal-router.
> Love that the whole thing is a few hundred lines of flexible, easy-to-read code.
>
> -- [Tweet](https://twitter.com/wincent/status/862115805378494464) by **Greg Hurrell** from Facebook
> It does a great job at trying to be _universal_ — it's not tied to any framework,
> it can be run on both server and client, and it's not even tied to history.
> It's a great library which does one thing: routing.
>
> -- [Comment on Reddit](https://www.reddit.com/r/reactjs/comments/5xhw3o#form-t1_dejkw4p367)
> by **@everdimension**
## Related Projects

@@ -254,4 +269,5 @@

Made with ♥ by
Konstantin Tarkus ([@koistya](https://twitter.com/koistya), [blog](https://medium.com/@tarkus)),
Vladimir Kutepov ([frenzzy](https://github.com/frenzzy)) and
[contributors](https://github.com/kriasoft/universal-router/graphs/contributors)
[Konstantin Tarkus](https://github.com/koistya)
([@koistya](https://twitter.com/koistya), [blog](https://medium.com/@tarkus)),
[Vladimir Kutepov](https://github.com/frenzzy)
and [contributors](https://github.com/kriasoft/universal-router/graphs/contributors)

@@ -18,3 +18,3 @@ /**

function cacheRoutes(routesByName, route, routes) {
if (routesByName[route.name]) {
if (routesByName.has(route.name)) {
throw new Error(`Route "${route.name}" already exists`);

@@ -24,3 +24,3 @@ }

if (route.name) {
routesByName[route.name] = route;
routesByName.set(route.name, route);
}

@@ -42,11 +42,11 @@

router.routesByName = router.routesByName || {};
router.routesByName = router.routesByName || new Map();
return (routeName, params) => {
let route = router.routesByName[routeName];
let route = router.routesByName.get(routeName);
if (!route) {
router.routesByName = {}; // clear cache
router.routesByName.clear(); // clear cache
cacheRoutes(router.routesByName, router.root, router.root.children);
route = router.routesByName[routeName];
route = router.routesByName.get(routeName);
if (!route) {

@@ -53,0 +53,0 @@ throw new Error(`Route "${routeName}" not found`);

@@ -27,3 +27,3 @@ /*! Universal Router | MIT License | https://www.kriasoft.com/universal-router/ */

function cacheRoutes(routesByName, route, routes) {
if (routesByName[route.name]) {
if (routesByName.has(route.name)) {
throw new Error('Route "' + route.name + '" already exists');

@@ -33,3 +33,3 @@ }

if (route.name) {
routesByName[route.name] = route;
routesByName.set(route.name, route);
}

@@ -53,11 +53,11 @@

router.routesByName = router.routesByName || {};
router.routesByName = router.routesByName || new Map();
return function (routeName, params) {
var route = router.routesByName[routeName];
var route = router.routesByName.get(routeName);
if (!route) {
router.routesByName = {}; // clear cache
router.routesByName.clear(); // clear cache
cacheRoutes(router.routesByName, router.root, router.root.children);
route = router.routesByName[routeName];
route = router.routesByName.get(routeName);
if (!route) {

@@ -64,0 +64,0 @@ throw new Error('Route "' + routeName + '" not found');

/*! Universal Router | MIT License | https://www.kriasoft.com/universal-router/ */
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r(require("./universal-router.min.js")):"function"==typeof define&&define.amd?define(["./universal-router.min.js"],r):e.generateUrls=r(e.UniversalRouter)}(this,function(e){"use strict";function r(e,t,n){if(e[t.name])throw new Error('Route "'+t.name+'" already exists');if(t.name&&(e[t.name]=t),n)for(var a=0;a<n.length;a+=1){var o=n[a];o.parent=t,r(e,o,o.children)}}function t(t){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(t instanceof e))throw new TypeError("An instance of UniversalRouter is expected");return t.routesByName=t.routesByName||{},function(e,i){var s=t.routesByName[e];if(!(s||(t.routesByName={},r(t.routesByName,t.root,t.root.children),s=t.routesByName[e])))throw new Error('Route "'+e+'" not found');var u=a.get(s.fullPath);if(!u){for(var f="",l=s;l;){var y=Array.isArray(l.path)?l.path[0]:l.path;y&&(f=y+f),l=l.parent}for(var h=n.parse(f),c=n.tokensToFunction(h),m=Object.create(null),p=0;p<h.length;p+=1)"string"!=typeof h[p]&&(m[h[p].name]=!0);u={toPath:c,keys:m},a.set(f,u),s.fullPath=f}var v=t.baseUrl+u.toPath(i,o)||"/";if(o.stringifyQueryParams&&i){for(var d={},g=Object.keys(i),w=0;w<g.length;w+=1){var P=g[w];u.keys[P]||(d[P]=i[P])}var B=o.stringifyQueryParams(d);B&&(v+="?"===B.charAt(0)?B:"?"+B)}return v}}var n=(e=e&&e.hasOwnProperty("default")?e.default:e).pathToRegexp,a=new Map;return e.generateUrls=t,t});
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r(require("./universal-router.min.js")):"function"==typeof define&&define.amd?define(["./universal-router.min.js"],r):e.generateUrls=r(e.UniversalRouter)}(this,function(e){"use strict";var r=(e=e&&e.hasOwnProperty("default")?e.default:e).pathToRegexp,t=new Map;function a(a){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(a instanceof e))throw new TypeError("An instance of UniversalRouter is expected");return a.routesByName=a.routesByName||new Map,function(e,o){var s=a.routesByName.get(e);if(!(s||(a.routesByName.clear(),function e(r,t,a){if(r.has(t.name))throw new Error('Route "'+t.name+'" already exists');if(t.name&&r.set(t.name,t),a)for(var n=0;n<a.length;n+=1){var o=a[n];o.parent=t,e(r,o,o.children)}}(a.routesByName,a.root,a.root.children),s=a.routesByName.get(e))))throw new Error('Route "'+e+'" not found');var i=t.get(s.fullPath);if(!i){for(var u="",f=s;f;){var l=Array.isArray(f.path)?f.path[0]:f.path;l&&(u=l+u),f=f.parent}for(var y=r.parse(u),h=r.tokensToFunction(y),c=Object.create(null),p=0;p<y.length;p+=1)"string"!=typeof y[p]&&(c[y[p].name]=!0);i={toPath:h,keys:c},t.set(u,i),s.fullPath=u}var m=a.baseUrl+i.toPath(o,n)||"/";if(n.stringifyQueryParams&&o){for(var v={},d=Object.keys(o),g=0;g<d.length;g+=1){var w=d[g];i.keys[w]||(v[w]=o[w])}var P=n.stringifyQueryParams(v);P&&(m+="?"===P.charAt(0)?P:"?"+P)}return m}}return e.generateUrls=a,a});
//# sourceMappingURL=universal-router-generate-urls.min.js.map
/*! 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||b,p=t&&t.delimiters||w,f=!1;null!==(o=E.exec(e));){var c=o[0],h=o[1],v=o.index;if(l+=e.slice(u,v),u=v+c.length,h)l+=h[1],f=!0;else{var d="",g=e[u],m=o[2],y=o[3],x=o[4],R=o[5];if(!f&&l.length){var j=l.length-1;p.indexOf(l[j])>-1&&(d=l[j],l=l.slice(0,j))}l&&(a.push(l),l="",f=!1);var k=""!==d&&void 0!==g&&g!==d,O="+"===R||"*"===R,T="?"===R||"*"===R,A=d||s,U=y||x;a.push({name:m||i++,prefix:d,delimiter:A,optional:T,repeat:O,partial:k,pattern:U?n(U):"[^"+r(A)+"]+?"})}}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||b),l=n.delimiters||w,s=[].concat(n.endsWith||[]).map(r).concat("$").join("|"),p="",f=!1,c=0;c<e.length;c++){var h=e[c];if("string"==typeof h)p+=r(h),f=c===e.length-1&&l.indexOf(h[h.length-1])>-1;else{var v=r(h.prefix),d=h.repeat?"(?:"+h.pattern+")(?:"+v+"(?:"+h.pattern+"))*":h.pattern;t&&t.push(h),h.optional?h.partial?p+=v+"("+d+")?":p+="(?:"+v+"("+d+"))?":p+=v+"("+d+")"}}return i?(a||(p+="(?:"+u+")?"),p+="$"===s?"$":"(?="+s+")"):(a||(p+="(?:"+u+"(?="+s+"))?"),f||(p+="(?="+u+"|"+s+")")),new RegExp("^"+p,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 f(e,t,r,n){var o=!e.children,a=(e.path||"")+"|"+o,i=j.get(a);if(!i){var u=[];i={keys:u,pattern:g(e.path||"",u,{end:o})},j.set(a,i)}var l=i.pattern.exec(t);if(!l)return null;for(var s=l[0],f=Object.assign({},n),c=1;c<l.length;c+=1){var h=i.keys[c-1],v=h.name,d=l[c];void 0===d&&R.call(f,v)||(h.repeat?f[v]=d?d.split(h.delimiter).map(p):[]:f[v]=d?p(d):d)}return{path:o||"/"!==s.charAt(s.length-1)?s:s.substr(1),keys:r.concat(i.keys),params:f}}function c(e,t,r,n,o){var a=void 0,i=void 0,u=0;return{next:function(l){if(e===l)return{done:!0};if(!a&&(a=f(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 s=e.children[u];s.parent=e,i=c(s,t+a.path,r.substr(a.path.length),a.keys,a.params)}var p=i.next(l);if(!p.done)return{done:!1,value:p.value};i=null,u+=1}return{done:!0}}}}function h(e,t){if("function"==typeof e.route.action)return e.route.action(e,t)}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="/",w="./",E=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 R=Object.prototype.hasOwnProperty,j=new Map,k=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}}(),O=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 k(e,[{key:"resolve",value:function(e){function t(e){var u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a.value.route,l=null===arguments[2]&&a.value.route;return a=i||n.next(l),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,r)}):(i=a,Promise.resolve(null))}var r=Object.assign({},this.context,"string"==typeof e?{pathname:e}:e),n=c(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 O.pathToRegexp=g,O.matchPath=f,O.matchRoute=c,O.resolveRoute=h,O});
!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";var e=h,t=l,r=function(e,t){return s(l(e,t))},n=s,o=c,a="/",i="./",u=new RegExp(["(\\\\.)","(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?"].join("|"),"g");function l(e,t){for(var r,n,o=[],l=0,s=0,f="",c=t&&t.delimiter||a,h=t&&t.delimiters||i,v=!1;null!==(r=u.exec(e));){var d=r[0],g=r[1],m=r.index;if(f+=e.slice(s,m),s=m+d.length,g)f+=g[1],v=!0;else{var y="",x=e[s],b=r[2],w=r[3],E=r[4],R=r[5];if(!v&&f.length){var j=f.length-1;h.indexOf(f[j])>-1&&(y=f[j],f=f.slice(0,j))}f&&(o.push(f),f="",v=!1);var k=""!==y&&void 0!==x&&x!==y,O="+"===R||"*"===R,T="?"===R||"*"===R,A=y||c,U=w||E;o.push({name:b||l++,prefix:y,delimiter:A,optional:T,repeat:O,partial:k,pattern:U?(n=U,n.replace(/([=!:$/()])/g,"\\$1")):"[^"+p(A)+"]+?"})}}return(f||s<e.length)&&o.push(f+e.substr(s)),o}function s(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 p(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function f(e){return e&&e.sensitive?"":"i"}function c(e,t,r){for(var n=(r=r||{}).strict,o=!1!==r.end,u=p(r.delimiter||a),l=r.delimiters||i,s=[].concat(r.endsWith||[]).map(p).concat("$").join("|"),c="",h=!1,v=0;v<e.length;v++){var d=e[v];if("string"==typeof d)c+=p(d),h=v===e.length-1&&l.indexOf(d[d.length-1])>-1;else{var g=p(d.prefix),m=d.repeat?"(?:"+d.pattern+")(?:"+g+"(?:"+d.pattern+"))*":d.pattern;t&&t.push(d),d.optional?d.partial?c+=g+"("+m+")?":c+="(?:"+g+"("+m+"))?":c+=g+"("+m+")"}}return o?(n||(c+="(?:"+u+")?"),c+="$"===s?"$":"(?="+s+")"):(n||(c+="(?:"+u+"(?="+s+"))?"),h||(c+="(?="+u+"|"+s+")")),new RegExp("^"+c,f(r))}function h(e,t,r){return e instanceof RegExp?function(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}(e,t):Array.isArray(e)?function(e,t,r){for(var n=[],o=0;o<e.length;o++)n.push(h(e[o],t,r).source);return new RegExp("(?:"+n.join("|")+")",f(r))}(e,t,r):(n=t,c(l(e,o=r),n,o));var n,o}e.parse=t,e.compile=r,e.tokensToFunction=n,e.tokensToRegExp=o;var v=Object.prototype.hasOwnProperty,d=new Map;function g(e){try{return decodeURIComponent(e)}catch(t){return e}}function m(t,r,n,o){var a=!t.children,i=(t.path||"")+"|"+a,u=d.get(i);if(!u){var l=[];u={keys:l,pattern:e(t.path||"",l,{end:a})},d.set(i,u)}var s=u.pattern.exec(r);if(!s)return null;for(var p=s[0],f=Object.assign({},o),c=1;c<s.length;c+=1){var h=u.keys[c-1],m=h.name,y=s[c];void 0===y&&v.call(f,m)||(h.repeat?f[m]=y?y.split(h.delimiter).map(g):[]:f[m]=y?g(y):y)}return{path:a||"/"!==p.charAt(p.length-1)?p:p.substr(1),keys:n.concat(u.keys),params:f}}function y(e,t,r,n,o){var a=void 0,i=void 0,u=0;return{next:function(l){if(e===l)return{done:!0};if(!a&&(a=m(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 s=e.children[u];s.parent=e,i=y(s,t+a.path,r.substr(a.path.length),a.keys,a.params)}var p=i.next(l);if(!p.done)return{done:!1,value:p.value};i=null,u+=1}return{done:!0}}}}function x(e,t){if("function"==typeof e.route.action)return e.route.action(e,t)}var b=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}}();var w=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Object(t)!==t)throw new TypeError("Invalid routes");this.baseUrl=r.baseUrl||"",this.resolveRoute=r.resolveRoute||x,this.context=Object.assign({router:this},r.context),this.root=Array.isArray(t)?{path:"",children:t,parent:null}:t,this.root.parent=null}return b(e,[{key:"resolve",value:function(e){var t=Object.assign({},this.context,"string"==typeof e?{pathname:e}:e),r=y(this.root,this.baseUrl,t.pathname.substr(this.baseUrl.length),[],null),n=this.resolveRoute,o=null,a=null;function i(e){var u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.value.route,l=null===arguments[2]&&o.value.route;return o=a||r.next(l),a=null,e||!o.done&&function(e,t){for(var r=t;r;)if((r=r.parent)===e)return!0;return!1}(u,o.value.route)?o.done?Promise.reject(Object.assign(new Error("Page not found"),{context:t,status:404,statusCode:404})):Promise.resolve(n(Object.assign({},t,o.value),o.value.params)).then(function(t){return null!==t&&void 0!==t?t:i(e,u,t)}):(a=o,Promise.resolve(null))}return t.next=i,i(!0,this.root)}}]),e}();return w.pathToRegexp=e,w.matchPath=m,w.matchRoute=y,w.resolveRoute=x,w});
//# 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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc