diff --git a/dist/universal-router-generate-urls.js b/dist/universal-router-generate-urls.js index 0d15fe9..7bc42ae 100644 --- a/dist/universal-router-generate-urls.js +++ b/dist/universal-router-generate-urls.js @@ -1,12 +1,11 @@ /*! Universal Router | MIT License | https://www.kriasoft.com/universal-router/ */ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./universal-router.js')) : - typeof define === 'function' && define.amd ? define(['./universal-router.js'], factory) : - (global = global || self, global.generateUrls = factory(global.UniversalRouter)); -}(this, function (UniversalRouter) { 'use strict'; + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('path-to-regexp')) : + typeof define === 'function' && define.amd ? define(['path-to-regexp'], factory) : + (global = global || self, global.generateUrls = factory(global.UniversalRouter.pathToRegexp)); +}(this, function (pathToRegexp) { 'use strict'; - var pathToRegexp = UniversalRouter.pathToRegexp; var cache = new Map(); function cacheRoutes(routesByName, route, routes) { @@ -32,8 +31,8 @@ options = {}; } - if (!(router instanceof UniversalRouter)) { - throw new TypeError('An instance of UniversalRouter is expected'); + if (!router) { + throw new ReferenceError('Router is not defined'); } router.routesByName = router.routesByName || new Map(); diff --git a/dist/universal-router-generate-urls.js.map b/dist/universal-router-generate-urls.js.map index c656193..e7a08c0 100644 --- a/dist/universal-router-generate-urls.js.map +++ b/dist/universal-router-generate-urls.js.map @@ -1 +1 @@ -{"version":3,"file":"universal-router-generate-urls.js","sources":["src/generateUrls.js"],"sourcesContent":["/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nimport UniversalRouter from './UniversalRouter'\n\nconst { pathToRegexp } = UniversalRouter\nconst cache = new Map()\n\nfunction cacheRoutes(routesByName, route, routes) {\n if (routesByName.has(route.name)) {\n throw new Error(`Route \"${route.name}\" already exists`)\n }\n\n if (route.name) {\n routesByName.set(route.name, route)\n }\n\n if (routes) {\n for (let i = 0; i < routes.length; i++) {\n const childRoute = routes[i]\n childRoute.parent = route\n cacheRoutes(routesByName, childRoute, childRoute.children)\n }\n }\n}\n\nfunction generateUrls(router, options = {}) {\n if (!(router instanceof UniversalRouter)) {\n throw new TypeError('An instance of UniversalRouter is expected')\n }\n\n router.routesByName = router.routesByName || new Map()\n\n return (routeName, params) => {\n let route = router.routesByName.get(routeName)\n if (!route) {\n router.routesByName.clear() // clear cache\n cacheRoutes(router.routesByName, router.root, router.root.children)\n\n route = router.routesByName.get(routeName)\n if (!route) {\n throw new Error(`Route \"${routeName}\" not found`)\n }\n }\n\n let regexp = cache.get(route.fullPath)\n if (!regexp) {\n let fullPath = ''\n let rt = route\n while (rt) {\n const path = Array.isArray(rt.path) ? rt.path[0] : rt.path\n if (path) {\n fullPath = path + fullPath\n }\n rt = rt.parent\n }\n const tokens = pathToRegexp.parse(fullPath)\n const toPath = pathToRegexp.tokensToFunction(tokens)\n const keys = Object.create(null)\n for (let i = 0; i < tokens.length; i++) {\n if (typeof tokens[i] !== 'string') {\n keys[tokens[i].name] = true\n }\n }\n regexp = { toPath, keys }\n cache.set(fullPath, regexp)\n route.fullPath = fullPath\n }\n\n let url = router.baseUrl + regexp.toPath(params, options) || '/'\n\n if (options.stringifyQueryParams && params) {\n const queryParams = {}\n const keys = Object.keys(params)\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i]\n if (!regexp.keys[key]) {\n queryParams[key] = params[key]\n }\n }\n const query = options.stringifyQueryParams(queryParams)\n if (query) {\n url += query.charAt(0) === '?' ? query : `?${query}`\n }\n }\n\n return url\n }\n}\n\nexport default generateUrls\n"],"names":["pathToRegexp","UniversalRouter","cache","Map","cacheRoutes","routesByName","route","routes","has","name","Error","set","i","length","childRoute","parent","children","generateUrls","router","options","TypeError","routeName","params","get","clear","root","regexp","fullPath","rt","path","Array","isArray","tokens","parse","toPath","tokensToFunction","keys","Object","create","url","baseUrl","stringifyQueryParams","queryParams","key","query","charAt"],"mappings":";;;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uB,IAAvB;EACD;EACF;;EACDiB,MAAAA,MAAM,GAAG;EAAEQ,QAAAA,MAAM,EAANA,MAAF;EAAUE,QAAAA,IAAI,EAAJA;EAAV,OAAT;EACAlC,MAAAA,KAAK,CAACS,GAAN,CAAUgB,QAAV,EAAoBD,MAApB;EACApB,MAAAA,KAAK,CAACqB,QAAN,GAAiBA,QAAjB;EACD;;EAED,QAAIY,GAAG,GAAGrB,MAAM,CAACsB,OAAP,GAAiBd,MAAM,CAACQ,MAAP,CAAcZ,MAAd,EAAsBH,OAAtB,CAAjB,IAAmD,GAA7D;;EAEA,QAAIA,OAAO,CAACsB,oBAAR,IAAgCnB,MAApC,EAA4C;EAC1C,UAAMoB,WAAW,GAAG,EAApB;;EACA,UAAMN,KAAI,GAAGC,MAAM,CAACD,IAAP,CAAYd,MAAZ,CAAb;;EACA,WAAK,IAAIV,EAAC,GAAG,CAAb,EAAgBA,EAAC,GAAGwB,KAAI,CAACvB,MAAzB,EAAiCD,EAAC,EAAlC,EAAsC;EACpC,YAAM+B,GAAG,GAAGP,KAAI,CAACxB,EAAD,CAAhB;;EACA,YAAI,CAACc,MAAM,CAACU,IAAP,CAAYO,GAAZ,CAAL,EAAuB;EACrBD,UAAAA,WAAW,CAACC,GAAD,CAAX,GAAmBrB,MAAM,CAACqB,GAAD,CAAzB;EACD;EACF;;EACD,UAAMC,KAAK,GAAGzB,OAAO,CAACsB,oBAAR,CAA6BC,WAA7B,CAAd;;EACA,UAAIE,KAAJ,EAAW;EACTL,QAAAA,GAAG,IAAIK,KAAK,CAACC,MAAN,CAAa,CAAb,MAAoB,GAApB,GAA0BD,KAA1B,SAAsCA,KAA7C;EACD;EACF;;EAED,WAAOL,GAAP;EACD,GAtDD;EAuDD;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"universal-router-generate-urls.js","sources":["src/generateUrls.js"],"sourcesContent":["/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nimport pathToRegexp from 'path-to-regexp'\n\nconst cache = new Map()\n\nfunction cacheRoutes(routesByName, route, routes) {\n if (routesByName.has(route.name)) {\n throw new Error(`Route \"${route.name}\" already exists`)\n }\n\n if (route.name) {\n routesByName.set(route.name, route)\n }\n\n if (routes) {\n for (let i = 0; i < routes.length; i++) {\n const childRoute = routes[i]\n childRoute.parent = route\n cacheRoutes(routesByName, childRoute, childRoute.children)\n }\n }\n}\n\nfunction generateUrls(router, options = {}) {\n if (!router) {\n throw new ReferenceError('Router is not defined')\n }\n\n router.routesByName = router.routesByName || new Map()\n\n return (routeName, params) => {\n let route = router.routesByName.get(routeName)\n if (!route) {\n router.routesByName.clear() // clear cache\n cacheRoutes(router.routesByName, router.root, router.root.children)\n\n route = router.routesByName.get(routeName)\n if (!route) {\n throw new Error(`Route \"${routeName}\" not found`)\n }\n }\n\n let regexp = cache.get(route.fullPath)\n if (!regexp) {\n let fullPath = ''\n let rt = route\n while (rt) {\n const path = Array.isArray(rt.path) ? rt.path[0] : rt.path\n if (path) {\n fullPath = path + fullPath\n }\n rt = rt.parent\n }\n const tokens = pathToRegexp.parse(fullPath)\n const toPath = pathToRegexp.tokensToFunction(tokens)\n const keys = Object.create(null)\n for (let i = 0; i < tokens.length; i++) {\n if (typeof tokens[i] !== 'string') {\n keys[tokens[i].name] = true\n }\n }\n regexp = { toPath, keys }\n cache.set(fullPath, regexp)\n route.fullPath = fullPath\n }\n\n let url = router.baseUrl + regexp.toPath(params, options) || '/'\n\n if (options.stringifyQueryParams && params) {\n const queryParams = {}\n const keys = Object.keys(params)\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i]\n if (!regexp.keys[key]) {\n queryParams[key] = params[key]\n }\n }\n const query = options.stringifyQueryParams(queryParams)\n if (query) {\n url += query.charAt(0) === '?' ? query : `?${query}`\n }\n }\n\n return url\n }\n}\n\nexport default generateUrls\n"],"names":["cache","Map","cacheRoutes","routesByName","route","routes","has","name","Error","set","i","length","childRoute","parent","children","generateUrls","router","options","ReferenceError","routeName","params","get","clear","root","regexp","fullPath","rt","path","Array","isArray","tokens","pathToRegexp","parse","toPath","tokensToFunction","keys","Object","create","url","baseUrl","stringifyQueryParams","queryParams","key","query","charAt"],"mappings":";;;;;;;;EAWA,IAAMA,KAAK,GAAG,IAAIC,GAAJ,EAAd;;EAEA,SAASC,WAAT,CAAqBC,YAArB,EAAmCC,KAAnC,EAA0CC,MAA1C,EAAkD;EAChD,MAAIF,YAAY,CAACG,GAAb,CAAiBF,KAAK,CAACG,IAAvB,CAAJ,EAAkC;EAChC,UAAM,IAAIC,KAAJ,cAAoBJ,KAAK,CAACG,IAA1B,uBAAN;EACD;;EAED,MAAIH,KAAK,CAACG,IAAV,EAAgB;EACdJ,IAAAA,YAAY,CAACM,GAAb,CAAiBL,KAAK,CAACG,IAAvB,EAA6BH,KAA7B;EACD;;EAED,MAAIC,MAAJ,EAAY;EACV,SAAK,IAAIK,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGL,MAAM,CAACM,MAA3B,EAAmCD,CAAC,EAApC,EAAwC;EACtC,UAAME,UAAU,GAAGP,MAAM,CAACK,CAAD,CAAzB;EACAE,MAAAA,UAAU,CAACC,MAAX,GAAoBT,KAApB;EACAF,MAAAA,WAAW,CAACC,YAAD,EAAeS,UAAf,EAA2BA,UAAU,CAACE,QAAtC,CAAX;EACD;EACF;EACF;;EAED,SAASC,YAAT,CAAsBC,MAAtB,EAA8BC,OAA9B,EAA4C;EAAA,MAAdA,OAAc;EAAdA,IAAAA,OAAc,GAAJ,EAAI;EAAA;;EAC1C,MAAI,CAACD,MAAL,EAAa;EACX,UAAM,IAAIE,cAAJ,CAAmB,uBAAnB,CAAN;EACD;;EAEDF,EAAAA,MAAM,CAACb,YAAP,GAAsBa,MAAM,CAACb,YAAP,IAAuB,IAAIF,GAAJ,EAA7C;EAEA,SAAO,UAACkB,SAAD,EAAYC,MAAZ,EAAuB;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at end of file diff --git a/dist/universal-router-generate-urls.min.js b/dist/universal-router-generate-urls.min.js index 49f6957..7f57206 100644 --- a/dist/universal-router-generate-urls.min.js +++ b/dist/universal-router-generate-urls.min.js @@ -1,3 +1,3 @@ /*! 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=e||self).generateUrls=r(e.UniversalRouter)}(this,function(e){"use strict";var w=e.pathToRegexp,B=new Map;return function(d,g){if(void 0===g&&(g={}),!(d instanceof e))throw new TypeError("An instance of UniversalRouter is expected");return d.routesByName=d.routesByName||new Map,function(e,r){var t=d.routesByName.get(e);if(!(t||(d.routesByName.clear(),function e(r,t,n){if(r.has(t.name))throw new Error('Route "'+t.name+'" already exists');if(t.name&&r.set(t.name,t),n)for(var a=0;a {\n let route = router.routesByName.get(routeName)\n if (!route) {\n router.routesByName.clear() // clear cache\n cacheRoutes(router.routesByName, router.root, router.root.children)\n\n route = router.routesByName.get(routeName)\n if (!route) {\n throw new Error(`Route \"${routeName}\" not found`)\n }\n }\n\n let regexp = cache.get(route.fullPath)\n if (!regexp) {\n let fullPath = ''\n let rt = route\n while (rt) {\n const path = Array.isArray(rt.path) ? rt.path[0] : rt.path\n if (path) {\n fullPath = path + fullPath\n }\n rt = rt.parent\n }\n const tokens = pathToRegexp.parse(fullPath)\n const toPath = pathToRegexp.tokensToFunction(tokens)\n const keys = Object.create(null)\n for (let i = 0; i < tokens.length; i++) {\n if (typeof tokens[i] !== 'string') {\n keys[tokens[i].name] = true\n }\n }\n regexp = { toPath, keys }\n cache.set(fullPath, regexp)\n route.fullPath = fullPath\n }\n\n let url = router.baseUrl + regexp.toPath(params, options) || '/'\n\n if (options.stringifyQueryParams && params) {\n const queryParams = {}\n const keys = Object.keys(params)\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i]\n if (!regexp.keys[key]) {\n queryParams[key] = params[key]\n }\n }\n const query = options.stringifyQueryParams(queryParams)\n if (query) {\n url += query.charAt(0) === '?' ? query : `?${query}`\n }\n }\n\n return url\n }\n}\n\nexport default generateUrls\n"],"names":["pathToRegexp","UniversalRouter","cache","Map","router","options","TypeError","routesByName","routeName","params","route","get","clear","cacheRoutes","routes","has","name","Error","set","i","length","childRoute","parent","children","root","regexp","fullPath","rt","path","Array","isArray","tokens","parse","toPath","tokensToFunction","keys","Object","create","url","baseUrl","stringifyQueryParams","queryParams","key","query","charAt"],"mappings":";0RAWQA,EAAiBC,EAAjBD,aACFE,EAAQ,IAAIC,WAoBlB,SAAsBC,EAAQC,eAAAA,IAAAA,EAAU,MAChCD,aAAkBH,SAChB,IAAIK,UAAU,qDAGtBF,EAAOG,aAAeH,EAAOG,cAAgB,IAAIJ,IAE1C,SAACK,EAAWC,OACbC,EAAQN,EAAOG,aAAaI,IAAIH,QAC/BE,IACHN,EAAOG,aAAaK,QA5B1B,SAASC,EAAYN,EAAcG,EAAOI,MACpCP,EAAaQ,IAAIL,EAAMM,YACnB,IAAIC,gBAAgBP,EAAMM,4BAG9BN,EAAMM,MACRT,EAAaW,IAAIR,EAAMM,KAAMN,GAG3BI,MACG,IAAIK,EAAI,EAAGA,EAAIL,EAAOM,OAAQD,IAAK,KAChCE,EAAaP,EAAOK,GAC1BE,EAAWC,OAASZ,EACpBG,EAAYN,EAAcc,EAAYA,EAAWE,WAgBjDV,CAAYT,EAAOG,aAAcH,EAAOoB,KAAMpB,EAAOoB,KAAKD,UAE1Db,EAAQN,EAAOG,aAAaI,IAAIH,WAExB,IAAIS,gBAAgBT,qBAI1BiB,EAASvB,EAAMS,IAAID,EAAMgB,cACxBD,EAAQ,SACPC,EAAW,GACXC,EAAKjB,EACFiB,GAAI,KACHC,EAAOC,MAAMC,QAAQH,EAAGC,MAAQD,EAAGC,KAAK,GAAKD,EAAGC,KAClDA,IACFF,EAAWE,EAAOF,GAEpBC,EAAKA,EAAGL,eAEJS,EAAS/B,EAAagC,MAAMN,GAC5BO,EAASjC,EAAakC,iBAAiBH,GACvCI,EAAOC,OAAOC,OAAO,MAClBlB,EAAI,EAAGA,EAAIY,EAAOX,OAAQD,IACR,iBAAdY,EAAOZ,KAChBgB,EAAKJ,EAAOZ,GAAGH,OAAQ,GAG3BS,EAAS,CAAEQ,OAAAA,EAAQE,KAAAA,GACnBjC,EAAMgB,IAAIQ,EAAUD,GACpBf,EAAMgB,SAAWA,MAGfY,EAAMlC,EAAOmC,QAAUd,EAAOQ,OAAOxB,EAAQJ,IAAY,OAEzDA,EAAQmC,sBAAwB/B,EAAQ,SACpCgC,EAAc,GACdN,EAAOC,OAAOD,KAAK1B,GAChBU,EAAI,EAAGA,EAAIgB,EAAKf,OAAQD,IAAK,KAC9BuB,EAAMP,EAAKhB,GACZM,EAAOU,KAAKO,KACfD,EAAYC,GAAOjC,EAAOiC,QAGxBC,EAAQtC,EAAQmC,qBAAqBC,GACvCE,IACFL,GAA2B,MAApBK,EAAMC,OAAO,GAAaD,MAAYA,UAI1CL"} \ No newline at end of file +{"version":3,"file":"universal-router-generate-urls.min.js","sources":["src/generateUrls.js"],"sourcesContent":["/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nimport pathToRegexp from 'path-to-regexp'\n\nconst cache = new Map()\n\nfunction cacheRoutes(routesByName, route, routes) {\n if (routesByName.has(route.name)) {\n throw new Error(`Route \"${route.name}\" already exists`)\n }\n\n if (route.name) {\n routesByName.set(route.name, route)\n }\n\n if (routes) {\n for (let i = 0; i < routes.length; i++) {\n const childRoute = routes[i]\n childRoute.parent = route\n cacheRoutes(routesByName, childRoute, childRoute.children)\n }\n }\n}\n\nfunction generateUrls(router, options = {}) {\n if (!router) {\n throw new ReferenceError('Router is not defined')\n }\n\n router.routesByName = router.routesByName || new Map()\n\n return (routeName, params) => {\n let route = router.routesByName.get(routeName)\n if (!route) {\n router.routesByName.clear() // clear cache\n cacheRoutes(router.routesByName, router.root, router.root.children)\n\n route = router.routesByName.get(routeName)\n if (!route) {\n throw new Error(`Route \"${routeName}\" not found`)\n }\n }\n\n let regexp = cache.get(route.fullPath)\n if (!regexp) {\n let fullPath = ''\n let rt = route\n while (rt) {\n const path = Array.isArray(rt.path) ? rt.path[0] : rt.path\n if (path) {\n fullPath = path + fullPath\n }\n rt = rt.parent\n }\n const tokens = pathToRegexp.parse(fullPath)\n const toPath = pathToRegexp.tokensToFunction(tokens)\n const keys = Object.create(null)\n for (let i = 0; i < tokens.length; i++) {\n if (typeof tokens[i] !== 'string') {\n keys[tokens[i].name] = true\n }\n }\n regexp = { toPath, keys }\n cache.set(fullPath, regexp)\n route.fullPath = fullPath\n }\n\n let url = router.baseUrl + regexp.toPath(params, options) || '/'\n\n if (options.stringifyQueryParams && params) {\n const queryParams = {}\n const keys = Object.keys(params)\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i]\n if (!regexp.keys[key]) {\n queryParams[key] = params[key]\n }\n }\n const query = options.stringifyQueryParams(queryParams)\n if (query) {\n url += query.charAt(0) === '?' ? query : `?${query}`\n }\n }\n\n return url\n }\n}\n\nexport default generateUrls\n"],"names":["cache","Map","router","options","ReferenceError","routesByName","routeName","params","route","get","clear","cacheRoutes","routes","has","name","Error","set","i","length","childRoute","parent","children","root","regexp","fullPath","rt","path","Array","isArray","tokens","pathToRegexp","parse","toPath","tokensToFunction","keys","Object","create","url","baseUrl","stringifyQueryParams","queryParams","key","query","charAt"],"mappings":";6QAWA,IAAMA,EAAQ,IAAIC,WAoBlB,SAAsBC,EAAQC,eAAAA,IAAAA,EAAU,KACjCD,QACG,IAAIE,eAAe,gCAG3BF,EAAOG,aAAeH,EAAOG,cAAgB,IAAIJ,IAE1C,SAACK,EAAWC,OACbC,EAAQN,EAAOG,aAAaI,IAAIH,QAC/BE,IACHN,EAAOG,aAAaK,QA5B1B,SAASC,EAAYN,EAAc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,GAAaD,MAAYA,UAI1CL"} \ No newline at end of file diff --git a/dist/universal-router-sync.js b/dist/universal-router-sync.js index b5538da..c426e7e 100644 --- a/dist/universal-router-sync.js +++ b/dist/universal-router-sync.js @@ -82,21 +82,22 @@ } function compile(str, options) { - return tokensToFunction(parse(str, options)); + return tokensToFunction(parse(str, options), options); } - function tokensToFunction(tokens) { + function tokensToFunction(tokens, options) { var matches = new Array(tokens.length); for (var i = 0; i < tokens.length; i++) { if (typeof tokens[i] === 'object') { - matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$'); + matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$', flags(options)); } } return function (data, options) { var path = ''; var encode = options && options.encode || encodeURIComponent; + var validate = options ? options.validate !== false : true; for (var i = 0; i < tokens.length; i++) { var token = tokens[i]; @@ -122,7 +123,7 @@ for (var j = 0; j < value.length; j++) { segment = encode(value[j], token); - if (!matches[i].test(segment)) { + if (validate && !matches[i].test(segment)) { throw new TypeError('Expected all "' + token.name + '" to match "' + token.pattern + '"'); } @@ -135,7 +136,7 @@ if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') { segment = encode(String(value), token); - if (!matches[i].test(segment)) { + if (validate && !matches[i].test(segment)) { throw new TypeError('Expected "' + token.name + '" to match "' + token.pattern + '", but got "' + segment + '"'); } diff --git a/dist/universal-router-sync.js.map b/dist/universal-router-sync.js.map index aa5e42c..5e8251e 100644 --- a/dist/universal-router-sync.js.map +++ b/dist/universal-router-sync.js.map @@ -1 +1 @@ -{"version":3,"file":"universal-router-sync.js","sources":["../node_modules/path-to-regexp/index.js","src/matchPath.js","src/matchRoute.js","src/resolveRoute.js","src/isChildRoute.js","src/UniversalRouterSync.js"],"sourcesContent":["/**\n * Expose `pathToRegexp`.\n */\nmodule.exports = pathToRegexp\nmodule.exports.parse = parse\nmodule.exports.compile = compile\nmodule.exports.tokensToFunction = tokensToFunction\nmodule.exports.tokensToRegExp = tokensToRegExp\n\n/**\n * Default configs.\n */\nvar DEFAULT_DELIMITER = '/'\n\n/**\n * The main path matching regexp utility.\n *\n * @type {RegExp}\n */\nvar PATH_REGEXP = new RegExp([\n // Match escaped characters that would otherwise appear in future matches.\n // This allows the user to escape special characters that won't transform.\n '(\\\\\\\\.)',\n // Match Express-style parameters and un-named parameters with a prefix\n // and optional suffixes. Matches appear as:\n //\n // \":test(\\\\d+)?\" => [\"test\", \"\\d+\", undefined, \"?\"]\n // \"(\\\\d+)\" => [undefined, undefined, \"\\d+\", undefined]\n '(?:\\\\:(\\\\w+)(?:\\\\(((?:\\\\\\\\.|[^\\\\\\\\()])+)\\\\))?|\\\\(((?:\\\\\\\\.|[^\\\\\\\\()])+)\\\\))([+*?])?'\n].join('|'), 'g')\n\n/**\n * Parse a string for the raw tokens.\n *\n * @param {string} str\n * @param {Object=} options\n * @return {!Array}\n */\nfunction parse (str, options) {\n var tokens = []\n var key = 0\n var index = 0\n var path = ''\n var defaultDelimiter = (options && options.delimiter) || DEFAULT_DELIMITER\n var whitelist = (options && options.whitelist) || undefined\n var pathEscaped = false\n var res\n\n while ((res = PATH_REGEXP.exec(str)) !== null) {\n var m = res[0]\n var escaped = res[1]\n var offset = res.index\n path += str.slice(index, offset)\n index = offset + m.length\n\n // Ignore already escaped sequences.\n if (escaped) {\n path += escaped[1]\n pathEscaped = true\n continue\n }\n\n var prev = ''\n var name = res[2]\n var capture = res[3]\n var group = res[4]\n var modifier = res[5]\n\n if (!pathEscaped && path.length) {\n var k = path.length - 1\n var c = path[k]\n var matches = whitelist ? whitelist.indexOf(c) > -1 : true\n\n if (matches) {\n prev = c\n path = path.slice(0, k)\n }\n }\n\n // Push the current path onto the tokens.\n if (path) {\n tokens.push(path)\n path = ''\n pathEscaped = false\n }\n\n var repeat = modifier === '+' || modifier === '*'\n var optional = modifier === '?' || modifier === '*'\n var pattern = capture || group\n var delimiter = prev || defaultDelimiter\n\n tokens.push({\n name: name || key++,\n prefix: prev,\n delimiter: delimiter,\n optional: optional,\n repeat: repeat,\n pattern: pattern\n ? escapeGroup(pattern)\n : '[^' + escapeString(delimiter === defaultDelimiter ? delimiter : (delimiter + defaultDelimiter)) + ']+?'\n })\n }\n\n // Push any remaining characters.\n if (path || index < str.length) {\n tokens.push(path + str.substr(index))\n }\n\n return tokens\n}\n\n/**\n * Compile a string to a template function for the path.\n *\n * @param {string} str\n * @param {Object=} options\n * @return {!function(Object=, Object=)}\n */\nfunction compile (str, options) {\n return tokensToFunction(parse(str, options))\n}\n\n/**\n * Expose a method for transforming tokens into the path function.\n */\nfunction tokensToFunction (tokens) {\n // Compile all the tokens into regexps.\n var matches = new Array(tokens.length)\n\n // Compile all the patterns before compilation.\n for (var i = 0; i < tokens.length; i++) {\n if (typeof tokens[i] === 'object') {\n matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$')\n }\n }\n\n return function (data, options) {\n var path = ''\n var encode = (options && options.encode) || encodeURIComponent\n\n for (var i = 0; i < tokens.length; i++) {\n var token = tokens[i]\n\n if (typeof token === 'string') {\n path += token\n continue\n }\n\n var value = data ? data[token.name] : undefined\n var segment\n\n if (Array.isArray(value)) {\n if (!token.repeat) {\n throw new TypeError('Expected \"' + token.name + '\" to not repeat, but got array')\n }\n\n if (value.length === 0) {\n if (token.optional) continue\n\n throw new TypeError('Expected \"' + token.name + '\" to not be empty')\n }\n\n for (var j = 0; j < value.length; j++) {\n segment = encode(value[j], token)\n\n if (!matches[i].test(segment)) {\n throw new TypeError('Expected all \"' + token.name + '\" to match \"' + token.pattern + '\"')\n }\n\n path += (j === 0 ? token.prefix : token.delimiter) + segment\n }\n\n continue\n }\n\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\n segment = encode(String(value), token)\n\n if (!matches[i].test(segment)) {\n throw new TypeError('Expected \"' + token.name + '\" to match \"' + token.pattern + '\", but got \"' + segment + '\"')\n }\n\n path += token.prefix + segment\n continue\n }\n\n if (token.optional) continue\n\n throw new TypeError('Expected \"' + token.name + '\" to be ' + (token.repeat ? 'an array' : 'a string'))\n }\n\n return path\n }\n}\n\n/**\n * Escape a regular expression string.\n *\n * @param {string} str\n * @return {string}\n */\nfunction escapeString (str) {\n return str.replace(/([.+*?=^!:${}()[\\]|/\\\\])/g, '\\\\$1')\n}\n\n/**\n * Escape the capturing group by escaping special characters and meaning.\n *\n * @param {string} group\n * @return {string}\n */\nfunction escapeGroup (group) {\n return group.replace(/([=!:$/()])/g, '\\\\$1')\n}\n\n/**\n * Get the flags for a regexp from the options.\n *\n * @param {Object} options\n * @return {string}\n */\nfunction flags (options) {\n return options && options.sensitive ? '' : 'i'\n}\n\n/**\n * Pull out keys from a regexp.\n *\n * @param {!RegExp} path\n * @param {Array=} keys\n * @return {!RegExp}\n */\nfunction regexpToRegexp (path, keys) {\n if (!keys) return path\n\n // Use a negative lookahead to match only capturing groups.\n var groups = path.source.match(/\\((?!\\?)/g)\n\n if (groups) {\n for (var i = 0; i < groups.length; i++) {\n keys.push({\n name: i,\n prefix: null,\n delimiter: null,\n optional: false,\n repeat: false,\n pattern: null\n })\n }\n }\n\n return path\n}\n\n/**\n * Transform an array into a regexp.\n *\n * @param {!Array} path\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction arrayToRegexp (path, keys, options) {\n var parts = []\n\n for (var i = 0; i < path.length; i++) {\n parts.push(pathToRegexp(path[i], keys, options).source)\n }\n\n return new RegExp('(?:' + parts.join('|') + ')', flags(options))\n}\n\n/**\n * Create a path regexp from string input.\n *\n * @param {string} path\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction stringToRegexp (path, keys, options) {\n return tokensToRegExp(parse(path, options), keys, options)\n}\n\n/**\n * Expose a function for taking tokens and returning a RegExp.\n *\n * @param {!Array} tokens\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction tokensToRegExp (tokens, keys, options) {\n options = options || {}\n\n var strict = options.strict\n var start = options.start !== false\n var end = options.end !== false\n var delimiter = options.delimiter || DEFAULT_DELIMITER\n var endsWith = [].concat(options.endsWith || []).map(escapeString).concat('$').join('|')\n var route = start ? '^' : ''\n\n // Iterate over the tokens and create our regexp string.\n for (var i = 0; i < tokens.length; i++) {\n var token = tokens[i]\n\n if (typeof token === 'string') {\n route += escapeString(token)\n } else {\n var capture = token.repeat\n ? '(?:' + token.pattern + ')(?:' + escapeString(token.delimiter) + '(?:' + token.pattern + '))*'\n : token.pattern\n\n if (keys) keys.push(token)\n\n if (token.optional) {\n if (!token.prefix) {\n route += '(' + capture + ')?'\n } else {\n route += '(?:' + escapeString(token.prefix) + '(' + capture + '))?'\n }\n } else {\n route += escapeString(token.prefix) + '(' + capture + ')'\n }\n }\n }\n\n if (end) {\n if (!strict) route += '(?:' + escapeString(delimiter) + ')?'\n\n route += endsWith === '$' ? '$' : '(?=' + endsWith + ')'\n } else {\n var endToken = tokens[tokens.length - 1]\n var isEndDelimited = typeof endToken === 'string'\n ? endToken[endToken.length - 1] === delimiter\n : endToken === undefined\n\n if (!strict) route += '(?:' + escapeString(delimiter) + '(?=' + endsWith + '))?'\n if (!isEndDelimited) route += '(?=' + escapeString(delimiter) + '|' + endsWith + ')'\n }\n\n return new RegExp(route, flags(options))\n}\n\n/**\n * Normalize the given path string, returning a regular expression.\n *\n * An empty array can be passed in for the keys, which will hold the\n * placeholder key descriptions. For example, using `/user/:id`, `keys` will\n * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.\n *\n * @param {(string|RegExp|Array)} path\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction pathToRegexp (path, keys, options) {\n if (path instanceof RegExp) {\n return regexpToRegexp(path, keys)\n }\n\n if (Array.isArray(path)) {\n return arrayToRegexp(/** @type {!Array} */ (path), keys, options)\n }\n\n return stringToRegexp(/** @type {string} */ (path), keys, options)\n}\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nimport pathToRegexp from 'path-to-regexp'\n\nconst { hasOwnProperty } = Object.prototype\nconst cache = new Map()\n\nfunction decodeParam(val) {\n try {\n return decodeURIComponent(val)\n } catch (err) {\n return val\n }\n}\n\nfunction matchPath(route, pathname, parentKeys, parentParams) {\n const end = !route.children\n const cacheKey = `${route.path || ''}|${end}`\n let regexp = cache.get(cacheKey)\n\n if (!regexp) {\n const keys = []\n regexp = {\n keys,\n pattern: pathToRegexp(route.path || '', keys, { end }),\n }\n cache.set(cacheKey, regexp)\n }\n\n const m = regexp.pattern.exec(pathname)\n if (!m) {\n return null\n }\n\n const path = m[0]\n const params = { ...parentParams }\n\n for (let i = 1; i < m.length; i++) {\n const key = regexp.keys[i - 1]\n const prop = key.name\n const value = m[i]\n if (value !== undefined || !hasOwnProperty.call(params, prop)) {\n if (key.repeat) {\n params[prop] = value ? value.split(key.delimiter).map(decodeParam) : []\n } else {\n params[prop] = value ? decodeParam(value) : value\n }\n }\n }\n\n return {\n path: !end && path.charAt(path.length - 1) === '/' ? path.substr(1) : path,\n keys: parentKeys.concat(regexp.keys),\n params,\n }\n}\n\nexport default matchPath\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nimport matchPath from './matchPath'\n\nfunction matchRoute(route, baseUrl, pathname, parentKeys, parentParams) {\n let match\n let childMatches\n let childIndex = 0\n\n return {\n next(routeToSkip) {\n if (route === routeToSkip) {\n return { done: true }\n }\n\n if (!match) {\n match = matchPath(route, pathname, parentKeys, parentParams)\n\n if (match) {\n return {\n done: false,\n value: {\n route,\n baseUrl,\n path: match.path,\n keys: match.keys,\n params: match.params,\n },\n }\n }\n }\n\n if (match && route.children) {\n while (childIndex < route.children.length) {\n if (!childMatches) {\n const childRoute = route.children[childIndex]\n childRoute.parent = route\n\n childMatches = matchRoute(\n childRoute,\n baseUrl + match.path,\n pathname.substr(match.path.length),\n match.keys,\n match.params,\n )\n }\n\n const childMatch = childMatches.next(routeToSkip)\n if (!childMatch.done) {\n return {\n done: false,\n value: childMatch.value,\n }\n }\n\n childMatches = null\n childIndex++\n }\n }\n\n return { done: true }\n },\n }\n}\n\nexport default matchRoute\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nfunction resolveRoute(context, params) {\n if (typeof context.route.action === 'function') {\n return context.route.action(context, params)\n }\n return undefined\n}\n\nexport default resolveRoute\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nfunction isChildRoute(parentRoute, childRoute) {\n let route = childRoute\n while (route) {\n route = route.parent\n if (route === parentRoute) {\n return true\n }\n }\n return false\n}\n\nexport default isChildRoute\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nimport pathToRegexp from 'path-to-regexp'\nimport matchRoute from './matchRoute'\nimport resolveRoute from './resolveRoute'\nimport isChildRoute from './isChildRoute'\n\nclass UniversalRouterSync {\n constructor(routes, options = {}) {\n if (!routes || typeof routes !== 'object') {\n throw new TypeError('Invalid routes')\n }\n\n this.baseUrl = options.baseUrl || ''\n this.errorHandler = options.errorHandler\n this.resolveRoute = options.resolveRoute || resolveRoute\n this.context = { router: this, ...options.context }\n this.root = Array.isArray(routes) ? { path: '', children: routes, parent: null } : routes\n this.root.parent = null\n }\n\n resolve(pathnameOrContext) {\n const context = {\n ...this.context,\n ...(typeof pathnameOrContext === 'string'\n ? { pathname: pathnameOrContext }\n : pathnameOrContext),\n }\n const match = matchRoute(\n this.root,\n this.baseUrl,\n context.pathname.substr(this.baseUrl.length),\n [],\n null,\n )\n const resolve = this.resolveRoute\n let matches = null\n let nextMatches = null\n let currentContext = context\n\n function next(resume, parent = matches.value.route, prevResult) {\n const routeToSkip = prevResult === null && !matches.done && matches.value.route\n matches = nextMatches || match.next(routeToSkip)\n nextMatches = null\n\n if (!resume) {\n if (matches.done || !isChildRoute(parent, matches.value.route)) {\n nextMatches = matches\n return null\n }\n }\n\n if (matches.done) {\n const error = new Error('Route not found')\n error.status = 404\n throw error\n }\n\n currentContext = { ...context, ...matches.value }\n\n const result = resolve(currentContext, matches.value.params)\n if (result !== null && result !== undefined) {\n return result\n }\n return next(resume, parent, result)\n }\n\n context.next = next\n\n try {\n return next(true, this.root)\n } catch (error) {\n if (this.errorHandler) {\n return this.errorHandler(error, currentContext)\n }\n throw error\n }\n }\n}\n\nUniversalRouterSync.pathToRegexp = pathToRegexp\n\nexport default UniversalRouterSync\n"],"names":["pathToRegexp","parse","compile","tokensToFunction","tokensToRegExp","DEFAULT_DELIMITER","PATH_REGEXP","RegExp","join","str","options","tokens","key","index","path","defaultDelimiter","delimiter","whitelist","undefined","pathEscaped","res","exec","m","escaped","offset","slice","length","prev","name","capture","group","modifier","k","c","matches","indexOf","push","repeat","optional","pattern","prefix","escapeGroup","escapeString","substr","Array","i","data","encode","encodeURIComponent","token","value","segment","isArray","TypeError","j","test","String","replace","flags","sensitive","regexpToRegexp","keys","groups","source","match","arrayToRegexp","parts","stringToRegexp","strict","start","end","endsWith","concat","map","route","endToken","isEndDelimited","hasOwnProperty","Object","prototype","cache","Map","decodeParam","val","decodeURIComponent","err","matchPath","pathname","parentKeys","parentParams","children","cacheKey","regexp","get","set","params","prop","call","split","charAt","matchRoute","baseUrl","childMatches","childIndex","next","routeToSkip","done","childRoute","parent","childMatch","resolveRoute","context","action","isChildRoute","parentRoute","UniversalRouterSync","routes","errorHandler","router","root","resolve","pathnameOrContext","nextMatches","currentContext","resume","prevResult","error","Error","status","result"],"mappings":";;;;;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O,GAAGwF,WAAW,IAAI1D,KAAK,CAACwC,IAAN,CAAWC,WAAX,CAAzB;EACAiB,MAAAA,WAAW,GAAG,IAAd;;EAEA,UAAI,CAACE,MAAL,EAAa;EACX,YAAI1F,OAAO,CAACwE,IAAR,IAAgB,CAACO,YAAY,CAACL,MAAD,EAAS1E,OAAO,CAACgB,KAAR,CAAcwB,KAAvB,CAAjC,EAAgE;EAC9DgD,UAAAA,WAAW,GAAGxF,OAAd;EACA,iBAAO,IAAP;EACD;EACF;;EAED,UAAIA,OAAO,CAACwE,IAAZ,EAAkB;EAChB,YAAMoB,KAAK,GAAG,IAAIC,KAAJ,CAAU,iBAAV,CAAd;EACAD,QAAAA,KAAK,CAACE,MAAN,GAAe,GAAf;EACA,cAAMF,KAAN;EACD;;EAEDH,MAAAA,cAAc,qBAAQZ,OAAR,MAAoB7E,OAAO,CAACgB,KAA5B,CAAd;EAEA,UAAM+E,MAAM,GAAGT,OAAO,CAACG,cAAD,EAAiBzF,OAAO,CAACgB,KAAR,CAAc6C,MAA/B,CAAtB;;EACA,UAAIkC,MAAM,KAAK,IAAX,IAAmBA,MAAM,KAAK/G,SAAlC,EAA6C;EAC3C,eAAO+G,MAAP;EACD;;EACD,aAAOzB,IAAI,CAACoB,MAAD,EAAShB,MAAT,EAAiBqB,MAAjB,CAAX;EACD;;EAEDlB,IAAAA,OAAO,CAACP,IAAR,GAAeA,IAAf;;EAEA,QAAI;EACF,aAAOA,IAAI,CAAC,IAAD,EAAO,KAAKe,IAAZ,CAAX;EACD,KAFD,CAEE,OAAOO,KAAP,EAAc;EACd,UAAI,KAAKT,YAAT,EAAuB;EACrB,eAAO,KAAKA,YAAL,CAAkBS,KAAlB,EAAyBH,cAAzB,CAAP;EACD;;EACD,YAAMG,KAAN;EACD;EACF;;;;;EAGHX,mBAAmB,CAACnH,YAApB,GAAmCA,cAAnC;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"universal-router-sync.js","sources":["../node_modules/path-to-regexp/index.js","src/matchPath.js","src/matchRoute.js","src/resolveRoute.js","src/isChildRoute.js","src/UniversalRouterSync.js"],"sourcesContent":["/**\n * Expose `pathToRegexp`.\n */\nmodule.exports = pathToRegexp\nmodule.exports.parse = parse\nmodule.exports.compile = compile\nmodule.exports.tokensToFunction = tokensToFunction\nmodule.exports.tokensToRegExp = tokensToRegExp\n\n/**\n * Default configs.\n */\nvar DEFAULT_DELIMITER = '/'\n\n/**\n * The main path matching regexp utility.\n *\n * @type {RegExp}\n */\nvar PATH_REGEXP = new RegExp([\n // Match escaped characters that would otherwise appear in future matches.\n // This allows the user to escape special characters that won't transform.\n '(\\\\\\\\.)',\n // Match Express-style parameters and un-named parameters with a prefix\n // and optional suffixes. Matches appear as:\n //\n // \":test(\\\\d+)?\" => [\"test\", \"\\d+\", undefined, \"?\"]\n // \"(\\\\d+)\" => [undefined, undefined, \"\\d+\", undefined]\n '(?:\\\\:(\\\\w+)(?:\\\\(((?:\\\\\\\\.|[^\\\\\\\\()])+)\\\\))?|\\\\(((?:\\\\\\\\.|[^\\\\\\\\()])+)\\\\))([+*?])?'\n].join('|'), 'g')\n\n/**\n * Parse a string for the raw tokens.\n *\n * @param {string} str\n * @param {Object=} options\n * @return {!Array}\n */\nfunction parse (str, options) {\n var tokens = []\n var key = 0\n var index = 0\n var path = ''\n var defaultDelimiter = (options && options.delimiter) || DEFAULT_DELIMITER\n var whitelist = (options && options.whitelist) || undefined\n var pathEscaped = false\n var res\n\n while ((res = PATH_REGEXP.exec(str)) !== null) {\n var m = res[0]\n var escaped = res[1]\n var offset = res.index\n path += str.slice(index, offset)\n index = offset + m.length\n\n // Ignore already escaped sequences.\n if (escaped) {\n path += escaped[1]\n pathEscaped = true\n continue\n }\n\n var prev = ''\n var name = res[2]\n var capture = res[3]\n var group = res[4]\n var modifier = res[5]\n\n if (!pathEscaped && path.length) {\n var k = path.length - 1\n var c = path[k]\n var matches = whitelist ? whitelist.indexOf(c) > -1 : true\n\n if (matches) {\n prev = c\n path = path.slice(0, k)\n }\n }\n\n // Push the current path onto the tokens.\n if (path) {\n tokens.push(path)\n path = ''\n pathEscaped = false\n }\n\n var repeat = modifier === '+' || modifier === '*'\n var optional = modifier === '?' || modifier === '*'\n var pattern = capture || group\n var delimiter = prev || defaultDelimiter\n\n tokens.push({\n name: name || key++,\n prefix: prev,\n delimiter: delimiter,\n optional: optional,\n repeat: repeat,\n pattern: pattern\n ? escapeGroup(pattern)\n : '[^' + escapeString(delimiter === defaultDelimiter ? delimiter : (delimiter + defaultDelimiter)) + ']+?'\n })\n }\n\n // Push any remaining characters.\n if (path || index < str.length) {\n tokens.push(path + str.substr(index))\n }\n\n return tokens\n}\n\n/**\n * Compile a string to a template function for the path.\n *\n * @param {string} str\n * @param {Object=} options\n * @return {!function(Object=, Object=)}\n */\nfunction compile (str, options) {\n return tokensToFunction(parse(str, options), options)\n}\n\n/**\n * Expose a method for transforming tokens into the path function.\n */\nfunction tokensToFunction (tokens, options) {\n // Compile all the tokens into regexps.\n var matches = new Array(tokens.length)\n\n // Compile all the patterns before compilation.\n for (var i = 0; i < tokens.length; i++) {\n if (typeof tokens[i] === 'object') {\n matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$', flags(options))\n }\n }\n\n return function (data, options) {\n var path = ''\n var encode = (options && options.encode) || encodeURIComponent\n var validate = options ? options.validate !== false : true\n\n for (var i = 0; i < tokens.length; i++) {\n var token = tokens[i]\n\n if (typeof token === 'string') {\n path += token\n continue\n }\n\n var value = data ? data[token.name] : undefined\n var segment\n\n if (Array.isArray(value)) {\n if (!token.repeat) {\n throw new TypeError('Expected \"' + token.name + '\" to not repeat, but got array')\n }\n\n if (value.length === 0) {\n if (token.optional) continue\n\n throw new TypeError('Expected \"' + token.name + '\" to not be empty')\n }\n\n for (var j = 0; j < value.length; j++) {\n segment = encode(value[j], token)\n\n if (validate && !matches[i].test(segment)) {\n throw new TypeError('Expected all \"' + token.name + '\" to match \"' + token.pattern + '\"')\n }\n\n path += (j === 0 ? token.prefix : token.delimiter) + segment\n }\n\n continue\n }\n\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\n segment = encode(String(value), token)\n\n if (validate && !matches[i].test(segment)) {\n throw new TypeError('Expected \"' + token.name + '\" to match \"' + token.pattern + '\", but got \"' + segment + '\"')\n }\n\n path += token.prefix + segment\n continue\n }\n\n if (token.optional) continue\n\n throw new TypeError('Expected \"' + token.name + '\" to be ' + (token.repeat ? 'an array' : 'a string'))\n }\n\n return path\n }\n}\n\n/**\n * Escape a regular expression string.\n *\n * @param {string} str\n * @return {string}\n */\nfunction escapeString (str) {\n return str.replace(/([.+*?=^!:${}()[\\]|/\\\\])/g, '\\\\$1')\n}\n\n/**\n * Escape the capturing group by escaping special characters and meaning.\n *\n * @param {string} group\n * @return {string}\n */\nfunction escapeGroup (group) {\n return group.replace(/([=!:$/()])/g, '\\\\$1')\n}\n\n/**\n * Get the flags for a regexp from the options.\n *\n * @param {Object} options\n * @return {string}\n */\nfunction flags (options) {\n return options && options.sensitive ? '' : 'i'\n}\n\n/**\n * Pull out keys from a regexp.\n *\n * @param {!RegExp} path\n * @param {Array=} keys\n * @return {!RegExp}\n */\nfunction regexpToRegexp (path, keys) {\n if (!keys) return path\n\n // Use a negative lookahead to match only capturing groups.\n var groups = path.source.match(/\\((?!\\?)/g)\n\n if (groups) {\n for (var i = 0; i < groups.length; i++) {\n keys.push({\n name: i,\n prefix: null,\n delimiter: null,\n optional: false,\n repeat: false,\n pattern: null\n })\n }\n }\n\n return path\n}\n\n/**\n * Transform an array into a regexp.\n *\n * @param {!Array} path\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction arrayToRegexp (path, keys, options) {\n var parts = []\n\n for (var i = 0; i < path.length; i++) {\n parts.push(pathToRegexp(path[i], keys, options).source)\n }\n\n return new RegExp('(?:' + parts.join('|') + ')', flags(options))\n}\n\n/**\n * Create a path regexp from string input.\n *\n * @param {string} path\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction stringToRegexp (path, keys, options) {\n return tokensToRegExp(parse(path, options), keys, options)\n}\n\n/**\n * Expose a function for taking tokens and returning a RegExp.\n *\n * @param {!Array} tokens\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction tokensToRegExp (tokens, keys, options) {\n options = options || {}\n\n var strict = options.strict\n var start = options.start !== false\n var end = options.end !== false\n var delimiter = options.delimiter || DEFAULT_DELIMITER\n var endsWith = [].concat(options.endsWith || []).map(escapeString).concat('$').join('|')\n var route = start ? '^' : ''\n\n // Iterate over the tokens and create our regexp string.\n for (var i = 0; i < tokens.length; i++) {\n var token = tokens[i]\n\n if (typeof token === 'string') {\n route += escapeString(token)\n } else {\n var capture = token.repeat\n ? '(?:' + token.pattern + ')(?:' + escapeString(token.delimiter) + '(?:' + token.pattern + '))*'\n : token.pattern\n\n if (keys) keys.push(token)\n\n if (token.optional) {\n if (!token.prefix) {\n route += '(' + capture + ')?'\n } else {\n route += '(?:' + escapeString(token.prefix) + '(' + capture + '))?'\n }\n } else {\n route += escapeString(token.prefix) + '(' + capture + ')'\n }\n }\n }\n\n if (end) {\n if (!strict) route += '(?:' + escapeString(delimiter) + ')?'\n\n route += endsWith === '$' ? '$' : '(?=' + endsWith + ')'\n } else {\n var endToken = tokens[tokens.length - 1]\n var isEndDelimited = typeof endToken === 'string'\n ? endToken[endToken.length - 1] === delimiter\n : endToken === undefined\n\n if (!strict) route += '(?:' + escapeString(delimiter) + '(?=' + endsWith + '))?'\n if (!isEndDelimited) route += '(?=' + escapeString(delimiter) + '|' + endsWith + ')'\n }\n\n return new RegExp(route, flags(options))\n}\n\n/**\n * Normalize the given path string, returning a regular expression.\n *\n * An empty array can be passed in for the keys, which will hold the\n * placeholder key descriptions. For example, using `/user/:id`, `keys` will\n * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.\n *\n * @param {(string|RegExp|Array)} path\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction pathToRegexp (path, keys, options) {\n if (path instanceof RegExp) {\n return regexpToRegexp(path, keys)\n }\n\n if (Array.isArray(path)) {\n return arrayToRegexp(/** @type {!Array} */ (path), keys, options)\n }\n\n return stringToRegexp(/** @type {string} */ (path), keys, options)\n}\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nimport pathToRegexp from 'path-to-regexp'\n\nconst { hasOwnProperty } = Object.prototype\nconst cache = new Map()\n\nfunction decodeParam(val) {\n try {\n return decodeURIComponent(val)\n } catch (err) {\n return val\n }\n}\n\nfunction matchPath(route, pathname, parentKeys, parentParams) {\n const end = !route.children\n const cacheKey = `${route.path || ''}|${end}`\n let regexp = cache.get(cacheKey)\n\n if (!regexp) {\n const keys = []\n regexp = {\n keys,\n pattern: pathToRegexp(route.path || '', keys, { end }),\n }\n cache.set(cacheKey, regexp)\n }\n\n const m = regexp.pattern.exec(pathname)\n if (!m) {\n return null\n }\n\n const path = m[0]\n const params = { ...parentParams }\n\n for (let i = 1; i < m.length; i++) {\n const key = regexp.keys[i - 1]\n const prop = key.name\n const value = m[i]\n if (value !== undefined || !hasOwnProperty.call(params, prop)) {\n if (key.repeat) {\n params[prop] = value ? value.split(key.delimiter).map(decodeParam) : []\n } else {\n params[prop] = value ? decodeParam(value) : value\n }\n }\n }\n\n return {\n path: !end && path.charAt(path.length - 1) === '/' ? path.substr(1) : path,\n keys: parentKeys.concat(regexp.keys),\n params,\n }\n}\n\nexport default matchPath\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nimport matchPath from './matchPath'\n\nfunction matchRoute(route, baseUrl, pathname, parentKeys, parentParams) {\n let match\n let childMatches\n let childIndex = 0\n\n return {\n next(routeToSkip) {\n if (route === routeToSkip) {\n return { done: true }\n }\n\n if (!match) {\n match = matchPath(route, pathname, parentKeys, parentParams)\n\n if (match) {\n return {\n done: false,\n value: {\n route,\n baseUrl,\n path: match.path,\n keys: match.keys,\n params: match.params,\n },\n }\n }\n }\n\n if (match && route.children) {\n while (childIndex < route.children.length) {\n if (!childMatches) {\n const childRoute = route.children[childIndex]\n childRoute.parent = route\n\n childMatches = matchRoute(\n childRoute,\n baseUrl + match.path,\n pathname.substr(match.path.length),\n match.keys,\n match.params,\n )\n }\n\n const childMatch = childMatches.next(routeToSkip)\n if (!childMatch.done) {\n return {\n done: false,\n value: childMatch.value,\n }\n }\n\n childMatches = null\n childIndex++\n }\n }\n\n return { done: true }\n },\n }\n}\n\nexport default matchRoute\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nfunction resolveRoute(context, params) {\n if (typeof context.route.action === 'function') {\n return context.route.action(context, params)\n }\n return undefined\n}\n\nexport default resolveRoute\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nfunction isChildRoute(parentRoute, childRoute) {\n let route = childRoute\n while (route) {\n route = route.parent\n if (route === parentRoute) {\n return true\n }\n }\n return false\n}\n\nexport default isChildRoute\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nimport pathToRegexp from 'path-to-regexp'\nimport matchRoute from './matchRoute'\nimport resolveRoute from './resolveRoute'\nimport isChildRoute from './isChildRoute'\n\nclass UniversalRouterSync {\n constructor(routes, options = {}) {\n if (!routes || typeof routes !== 'object') {\n throw new TypeError('Invalid routes')\n }\n\n this.baseUrl = options.baseUrl || ''\n this.errorHandler = options.errorHandler\n this.resolveRoute = options.resolveRoute || resolveRoute\n this.context = { router: this, ...options.context }\n this.root = Array.isArray(routes) ? { path: '', children: routes, parent: null } : routes\n this.root.parent = null\n }\n\n resolve(pathnameOrContext) {\n const context = {\n ...this.context,\n ...(typeof pathnameOrContext === 'string'\n ? { pathname: pathnameOrContext }\n : pathnameOrContext),\n }\n const match = matchRoute(\n this.root,\n this.baseUrl,\n context.pathname.substr(this.baseUrl.length),\n [],\n null,\n )\n const resolve = this.resolveRoute\n let matches = null\n let nextMatches = null\n let currentContext = context\n\n function next(resume, parent = matches.value.route, prevResult) {\n const routeToSkip = prevResult === null && !matches.done && matches.value.route\n matches = nextMatches || match.next(routeToSkip)\n nextMatches = null\n\n if (!resume) {\n if (matches.done || !isChildRoute(parent, matches.value.route)) {\n nextMatches = matches\n return null\n }\n }\n\n if (matches.done) {\n const error = new Error('Route not found')\n error.status = 404\n throw error\n }\n\n currentContext = { ...context, ...matches.value }\n\n const result = resolve(currentContext, matches.value.params)\n if (result !== null && result !== undefined) {\n return result\n }\n return next(resume, parent, result)\n }\n\n context.next = next\n\n try {\n return next(true, this.root)\n } catch (error) {\n if (this.errorHandler) {\n return this.errorHandler(error, currentContext)\n }\n throw error\n }\n }\n}\n\nUniversalRouterSync.pathToRegexp = pathToRegexp\n\nexport default UniversalRouterSync\n"],"names":["pathToRegexp","parse","compile","tokensToFunction","tokensToRegExp","DEFAULT_DELIMITER","PATH_REGEXP","RegExp","join","str","options","tokens","key","index","path","defaultDelimiter","delimiter","whitelist","undefined","pathEscaped","res","exec","m","escaped","offset","slice","length","prev","name","capture","group","modifier","k","c","matches","indexOf","push","repeat","optional","pattern","prefix","escapeGroup","escapeString","substr","Array","i","flags","data","encode","encodeURIComponent","validate","token","value","segment","isArray","TypeError","j","test","String","replace","sensitive","regexpToRegexp","keys","groups","source","match","arrayToRegexp","parts","stringToRegexp","strict","start","end","endsWith","concat","map","route","endToken","isEndDelimited","hasOwnProperty","Object","prototype","cache","Map","decodeParam","val","decodeURIComponent","err","matchPath","pathname","parentKeys","parentParams","children","cacheKey","regexp","get","set","params","prop","call","split","charAt","matchRoute","baseUrl","childMatches","childIndex","next","routeToSkip","done","childRoute","parent","childMatch","resolveRoute","context","action","isChildRoute","parentRoute","UniversalRouterSync","routes","errorHandler","router","root","resolve","pathnameOrContext","nextMatches","currentContext","resume","prevResult","error","Error","status","result"],"mappings":";;;;;;;;EAGA,kBAAc,GAAGA,YAAjB;EACA,WAAoB,GAAGC,KAAvB;EACA,aAAsB,GAAGC,OAAzB;EACA,sBAA+B,GAAGC,gBAAlC;EACA,oBAA6B,GAAGC,cAAhC;EAKA,IAAIC,iBAAiB,GAAG,GAAxB;EAOA,IAAIC,WAAW,GAAG,IAAIC,MAAJ,CAAW,CAG3B,SAH2B,EAS3B,qFAT2B,EAU3BC,IAV2B,CAUtB,GAVsB,CAAX,EAUL,GAVK,CAAlB;;EAmBA,SAASP,KAAT,CAAgBQ,GAAhB,EAAqBC,OAArB,EAA8B;EAC5B,MAAIC,MAAM,GAAG,EAAb;EACA,MAAIC,GAAG,GAAG,CAAV;EACA,MAAIC,KAAK,GAAG,CAAZ;EACA,MAAIC,IAAI,GAAG,EAAX;EACA,MAAIC,gBAAgB,GAAIL,OAAO,IAAIA,OAAO,CAACM,SAApB,IAAkCX,iBAAzD;EACA,MAAIY,SAAS,GAAIP,OAAO,IAAIA,OAAO,CAACO,SAApB,IAAkCC,SAAlD;EACA,MAAIC,WAAW,GAAG,KAAlB;EACA,MAAIC,GAAJ;;EAEA,SAAO,CAACA,GAAG,GAAGd,WAAW,CAACe,IAAZ,CAAiBZ,GAAjB,CAAP,MAAkC,IAAzC,EAA+C;EAC7C,QAAIa,CAAC,GAAGF,GAAG,CAAC,CAAD,CAAX;EACA,QAAIG,OAAO,GAAGH,GAAG,CAAC,CAAD,CAAjB;EACA,QAAII,MAAM,GAAGJ,GAAG,CAACP,KAAjB;EACAC,IAAAA,IA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AOzB,IAAI,CAACoB,MAAD,EAAShB,MAAT,EAAiBqB,MAAjB,CAAX;EACD;;EAEDlB,IAAAA,OAAO,CAACP,IAAR,GAAeA,IAAf;;EAEA,QAAI;EACF,aAAOA,IAAI,CAAC,IAAD,EAAO,KAAKe,IAAZ,CAAX;EACD,KAFD,CAEE,OAAOO,KAAP,EAAc;EACd,UAAI,KAAKT,YAAT,EAAuB;EACrB,eAAO,KAAKA,YAAL,CAAkBS,KAAlB,EAAyBH,cAAzB,CAAP;EACD;;EACD,YAAMG,KAAN;EACD;EACF;;;;;EAGHX,mBAAmB,CAACpH,YAApB,GAAmCA,cAAnC;;;;;;;;"} \ No newline at end of file diff --git a/dist/universal-router-sync.min.js b/dist/universal-router-sync.min.js index 8b779d1..39584bf 100644 --- a/dist/universal-router-sync.min.js +++ b/dist/universal-router-sync.min.js @@ -1,3 +1,3 @@ /*! 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=e||self).UniversalRouterSync=t()}(this,function(){"use strict";function e(e,t){return a(o(e,t))}var v=u,t=o,r=a,n=i,k="/",T=new RegExp(["(\\\\.)","(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?"].join("|"),"g");function o(e,t){for(var r,n,o=[],a=0,i=0,u="",l=t&&t.delimiter||k,p=t&&t.whitelist||void 0,s=!1;null!==(r=T.exec(e));){var f=r[0],c=r[1],h=r.index;if(u+=e.slice(i,h),i=h+f.length,c)u+=c[1],s=!0;else{var d="",v=r[2],g=r[3],y=r[4],m=r[5];if(!s&&u.length){var x=u.length-1,w=u[x];(!p||-1 [\"test\", \"\\d+\", undefined, \"?\"]\n // \"(\\\\d+)\" => [undefined, undefined, \"\\d+\", undefined]\n '(?:\\\\:(\\\\w+)(?:\\\\(((?:\\\\\\\\.|[^\\\\\\\\()])+)\\\\))?|\\\\(((?:\\\\\\\\.|[^\\\\\\\\()])+)\\\\))([+*?])?'\n].join('|'), 'g')\n\n/**\n * Parse a string for the raw tokens.\n *\n * @param {string} str\n * @param {Object=} options\n * @return {!Array}\n */\nfunction parse (str, options) {\n var tokens = []\n var key = 0\n var index = 0\n var path = ''\n var defaultDelimiter = (options && options.delimiter) || DEFAULT_DELIMITER\n var whitelist = (options && options.whitelist) || undefined\n var pathEscaped = false\n var res\n\n while ((res = PATH_REGEXP.exec(str)) !== null) {\n var m = res[0]\n var escaped = res[1]\n var offset = res.index\n path += str.slice(index, offset)\n index = offset + m.length\n\n // Ignore already escaped sequences.\n if (escaped) {\n path += escaped[1]\n pathEscaped = true\n continue\n }\n\n var prev = ''\n var name = res[2]\n var capture = res[3]\n var group = res[4]\n var modifier = res[5]\n\n if (!pathEscaped && path.length) {\n var k = path.length - 1\n var c = path[k]\n var matches = whitelist ? whitelist.indexOf(c) > -1 : true\n\n if (matches) {\n prev = c\n path = path.slice(0, k)\n }\n }\n\n // Push the current path onto the tokens.\n if (path) {\n tokens.push(path)\n path = ''\n pathEscaped = false\n }\n\n var repeat = modifier === '+' || modifier === '*'\n var optional = modifier === '?' || modifier === '*'\n var pattern = capture || group\n var delimiter = prev || defaultDelimiter\n\n tokens.push({\n name: name || key++,\n prefix: prev,\n delimiter: delimiter,\n optional: optional,\n repeat: repeat,\n pattern: pattern\n ? escapeGroup(pattern)\n : '[^' + escapeString(delimiter === defaultDelimiter ? delimiter : (delimiter + defaultDelimiter)) + ']+?'\n })\n }\n\n // Push any remaining characters.\n if (path || index < str.length) {\n tokens.push(path + str.substr(index))\n }\n\n return tokens\n}\n\n/**\n * Compile a string to a template function for the path.\n *\n * @param {string} str\n * @param {Object=} options\n * @return {!function(Object=, Object=)}\n */\nfunction compile (str, options) {\n return tokensToFunction(parse(str, options))\n}\n\n/**\n * Expose a method for transforming tokens into the path function.\n */\nfunction tokensToFunction (tokens) {\n // Compile all the tokens into regexps.\n var matches = new Array(tokens.length)\n\n // Compile all the patterns before compilation.\n for (var i = 0; i < tokens.length; i++) {\n if (typeof tokens[i] === 'object') {\n matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$')\n }\n }\n\n return function (data, options) {\n var path = ''\n var encode = (options && options.encode) || encodeURIComponent\n\n for (var i = 0; i < tokens.length; i++) {\n var token = tokens[i]\n\n if (typeof token === 'string') {\n path += token\n continue\n }\n\n var value = data ? data[token.name] : undefined\n var segment\n\n if (Array.isArray(value)) {\n if (!token.repeat) {\n throw new TypeError('Expected \"' + token.name + '\" to not repeat, but got array')\n }\n\n if (value.length === 0) {\n if (token.optional) continue\n\n throw new TypeError('Expected \"' + token.name + '\" to not be empty')\n }\n\n for (var j = 0; j < value.length; j++) {\n segment = encode(value[j], token)\n\n if (!matches[i].test(segment)) {\n throw new TypeError('Expected all \"' + token.name + '\" to match \"' + token.pattern + '\"')\n }\n\n path += (j === 0 ? token.prefix : token.delimiter) + segment\n }\n\n continue\n }\n\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\n segment = encode(String(value), token)\n\n if (!matches[i].test(segment)) {\n throw new TypeError('Expected \"' + token.name + '\" to match \"' + token.pattern + '\", but got \"' + segment + '\"')\n }\n\n path += token.prefix + segment\n continue\n }\n\n if (token.optional) continue\n\n throw new TypeError('Expected \"' + token.name + '\" to be ' + (token.repeat ? 'an array' : 'a string'))\n }\n\n return path\n }\n}\n\n/**\n * Escape a regular expression string.\n *\n * @param {string} str\n * @return {string}\n */\nfunction escapeString (str) {\n return str.replace(/([.+*?=^!:${}()[\\]|/\\\\])/g, '\\\\$1')\n}\n\n/**\n * Escape the capturing group by escaping special characters and meaning.\n *\n * @param {string} group\n * @return {string}\n */\nfunction escapeGroup (group) {\n return group.replace(/([=!:$/()])/g, '\\\\$1')\n}\n\n/**\n * Get the flags for a regexp from the options.\n *\n * @param {Object} options\n * @return {string}\n */\nfunction flags (options) {\n return options && options.sensitive ? '' : 'i'\n}\n\n/**\n * Pull out keys from a regexp.\n *\n * @param {!RegExp} path\n * @param {Array=} keys\n * @return {!RegExp}\n */\nfunction regexpToRegexp (path, keys) {\n if (!keys) return path\n\n // Use a negative lookahead to match only capturing groups.\n var groups = path.source.match(/\\((?!\\?)/g)\n\n if (groups) {\n for (var i = 0; i < groups.length; i++) {\n keys.push({\n name: i,\n prefix: null,\n delimiter: null,\n optional: false,\n repeat: false,\n pattern: null\n })\n }\n }\n\n return path\n}\n\n/**\n * Transform an array into a regexp.\n *\n * @param {!Array} path\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction arrayToRegexp (path, keys, options) {\n var parts = []\n\n for (var i = 0; i < path.length; i++) {\n parts.push(pathToRegexp(path[i], keys, options).source)\n }\n\n return new RegExp('(?:' + parts.join('|') + ')', flags(options))\n}\n\n/**\n * Create a path regexp from string input.\n *\n * @param {string} path\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction stringToRegexp (path, keys, options) {\n return tokensToRegExp(parse(path, options), keys, options)\n}\n\n/**\n * Expose a function for taking tokens and returning a RegExp.\n *\n * @param {!Array} tokens\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction tokensToRegExp (tokens, keys, options) {\n options = options || {}\n\n var strict = options.strict\n var start = options.start !== false\n var end = options.end !== false\n var delimiter = options.delimiter || DEFAULT_DELIMITER\n var endsWith = [].concat(options.endsWith || []).map(escapeString).concat('$').join('|')\n var route = start ? '^' : ''\n\n // Iterate over the tokens and create our regexp string.\n for (var i = 0; i < tokens.length; i++) {\n var token = tokens[i]\n\n if (typeof token === 'string') {\n route += escapeString(token)\n } else {\n var capture = token.repeat\n ? '(?:' + token.pattern + ')(?:' + escapeString(token.delimiter) + '(?:' + token.pattern + '))*'\n : token.pattern\n\n if (keys) keys.push(token)\n\n if (token.optional) {\n if (!token.prefix) {\n route += '(' + capture + ')?'\n } else {\n route += '(?:' + escapeString(token.prefix) + '(' + capture + '))?'\n }\n } else {\n route += escapeString(token.prefix) + '(' + capture + ')'\n }\n }\n }\n\n if (end) {\n if (!strict) route += '(?:' + escapeString(delimiter) + ')?'\n\n route += endsWith === '$' ? '$' : '(?=' + endsWith + ')'\n } else {\n var endToken = tokens[tokens.length - 1]\n var isEndDelimited = typeof endToken === 'string'\n ? endToken[endToken.length - 1] === delimiter\n : endToken === undefined\n\n if (!strict) route += '(?:' + escapeString(delimiter) + '(?=' + endsWith + '))?'\n if (!isEndDelimited) route += '(?=' + escapeString(delimiter) + '|' + endsWith + ')'\n }\n\n return new RegExp(route, flags(options))\n}\n\n/**\n * Normalize the given path string, returning a regular expression.\n *\n * An empty array can be passed in for the keys, which will hold the\n * placeholder key descriptions. For example, using `/user/:id`, `keys` will\n * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.\n *\n * @param {(string|RegExp|Array)} path\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction pathToRegexp (path, keys, options) {\n if (path instanceof RegExp) {\n return regexpToRegexp(path, keys)\n }\n\n if (Array.isArray(path)) {\n return arrayToRegexp(/** @type {!Array} */ (path), keys, options)\n }\n\n return stringToRegexp(/** @type {string} */ (path), keys, options)\n}\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nimport pathToRegexp from 'path-to-regexp'\n\nconst { hasOwnProperty } = Object.prototype\nconst cache = new Map()\n\nfunction decodeParam(val) {\n try {\n return decodeURIComponent(val)\n } catch (err) {\n return val\n }\n}\n\nfunction matchPath(route, pathname, parentKeys, parentParams) {\n const end = !route.children\n const cacheKey = `${route.path || ''}|${end}`\n let regexp = cache.get(cacheKey)\n\n if (!regexp) {\n const keys = []\n regexp = {\n keys,\n pattern: pathToRegexp(route.path || '', keys, { end }),\n }\n cache.set(cacheKey, regexp)\n }\n\n const m = regexp.pattern.exec(pathname)\n if (!m) {\n return null\n }\n\n const path = m[0]\n const params = { ...parentParams }\n\n for (let i = 1; i < m.length; i++) {\n const key = regexp.keys[i - 1]\n const prop = key.name\n const value = m[i]\n if (value !== undefined || !hasOwnProperty.call(params, prop)) {\n if (key.repeat) {\n params[prop] = value ? value.split(key.delimiter).map(decodeParam) : []\n } else {\n params[prop] = value ? decodeParam(value) : value\n }\n }\n }\n\n return {\n path: !end && path.charAt(path.length - 1) === '/' ? path.substr(1) : path,\n keys: parentKeys.concat(regexp.keys),\n params,\n }\n}\n\nexport default matchPath\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nimport matchPath from './matchPath'\n\nfunction matchRoute(route, baseUrl, pathname, parentKeys, parentParams) {\n let match\n let childMatches\n let childIndex = 0\n\n return {\n next(routeToSkip) {\n if (route === routeToSkip) {\n return { done: true }\n }\n\n if (!match) {\n match = matchPath(route, pathname, parentKeys, parentParams)\n\n if (match) {\n return {\n done: false,\n value: {\n route,\n baseUrl,\n path: match.path,\n keys: match.keys,\n params: match.params,\n },\n }\n }\n }\n\n if (match && route.children) {\n while (childIndex < route.children.length) {\n if (!childMatches) {\n const childRoute = route.children[childIndex]\n childRoute.parent = route\n\n childMatches = matchRoute(\n childRoute,\n baseUrl + match.path,\n pathname.substr(match.path.length),\n match.keys,\n match.params,\n )\n }\n\n const childMatch = childMatches.next(routeToSkip)\n if (!childMatch.done) {\n return {\n done: false,\n value: childMatch.value,\n }\n }\n\n childMatches = null\n childIndex++\n }\n }\n\n return { done: true }\n },\n }\n}\n\nexport default matchRoute\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nfunction resolveRoute(context, params) {\n if (typeof context.route.action === 'function') {\n return context.route.action(context, params)\n }\n return undefined\n}\n\nexport default resolveRoute\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nimport pathToRegexp from 'path-to-regexp'\nimport matchRoute from './matchRoute'\nimport resolveRoute from './resolveRoute'\nimport isChildRoute from './isChildRoute'\n\nclass UniversalRouterSync {\n constructor(routes, options = {}) {\n if (!routes || typeof routes !== 'object') {\n throw new TypeError('Invalid routes')\n }\n\n this.baseUrl = options.baseUrl || ''\n this.errorHandler = options.errorHandler\n this.resolveRoute = options.resolveRoute || resolveRoute\n this.context = { router: this, ...options.context }\n this.root = Array.isArray(routes) ? { path: '', children: routes, parent: null } : routes\n this.root.parent = null\n }\n\n resolve(pathnameOrContext) {\n const context = {\n ...this.context,\n ...(typeof pathnameOrContext === 'string'\n ? { pathname: pathnameOrContext }\n : pathnameOrContext),\n }\n const match = matchRoute(\n this.root,\n this.baseUrl,\n context.pathname.substr(this.baseUrl.length),\n [],\n null,\n )\n const resolve = this.resolveRoute\n let matches = null\n let nextMatches = null\n let currentContext = context\n\n function next(resume, parent = matches.value.route, prevResult) {\n const routeToSkip = prevResult === null && !matches.done && matches.value.route\n matches = nextMatches || match.next(routeToSkip)\n nextMatches = null\n\n if (!resume) {\n if (matches.done || !isChildRoute(parent, matches.value.route)) {\n nextMatches = matches\n return null\n }\n }\n\n if (matches.done) {\n const error = new Error('Route not found')\n error.status = 404\n throw error\n }\n\n currentContext = { ...context, ...matches.value }\n\n const result = resolve(currentContext, matches.value.params)\n if (result !== null && result !== undefined) {\n return result\n }\n return next(resume, parent, result)\n }\n\n context.next = next\n\n try {\n return next(true, this.root)\n } catch (error) {\n if (this.errorHandler) {\n return this.errorHandler(error, currentContext)\n }\n throw error\n }\n }\n}\n\nUniversalRouterSync.pathToRegexp = pathToRegexp\n\nexport default UniversalRouterSync\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nfunction isChildRoute(parentRoute, childRoute) {\n let route = childRoute\n while (route) {\n route = route.parent\n if (route === parentRoute) {\n return true\n }\n }\n return false\n}\n\nexport default isChildRoute\n"],"names":["str","options","tokensToFunction","parse","pathToRegexp","tokensToRegExp","DEFAULT_DELIMITER","PATH_REGEXP","RegExp","join","res","group","tokens","key","index","path","defaultDelimiter","delimiter","whitelist","undefined","pathEscaped","exec","m","escaped","offset","slice","length","prev","name","capture","modifier","k","c","indexOf","push","repeat","optional","pattern","prefix","replace","escapeString","substr","matches","Array","i","data","encode","encodeURIComponent","token","segment","value","isArray","TypeError","j","test","String","flags","sensitive","keys","strict","start","end","endsWith","concat","map","route","endToken","isEndDelimited","groups","source","match","regexpToRegexp","parts","arrayToRegexp","stringToRegexp","hasOwnProperty","Object","prototype","cache","Map","decodeParam","val","decodeURIComponent","err","matchRoute","baseUrl","pathname","parentKeys","parentParams","childMatches","childIndex","next","routeToSkip","done","children","cacheKey","regexp","get","set","params","prop","call","split","charAt","matchPath","childRoute","parent","childMatch","resolveRoute","context","action","UniversalRouterSync","resolve","pathnameOrContext","this","root","nextMatches","currentContext","resume","prevResult","parentRoute","isChildRoute","error","Error","status","result","errorHandler","routes","router"],"mappings":";yMAsHA,WAAkBA,EAAKC,UACdC,EAAiBC,EAAMH,EAAKC,IApHrC,MAAiBG,IACMD,IAEWD,IACFG,EAK5BC,EAAoB,IAOpBC,EAAc,IAAIC,OAAO,CAG3B,UAMA,uFACAC,KAAK,KAAM,KASb,SAASN,EAAOH,EAAKC,WAQfS,EAqKgBC,EA5KhBC,EAAS,GACTC,EAAM,EACNC,EAAQ,EACRC,EAAO,GACPC,EAAoBf,GAAWA,EAAQgB,WAAcX,EACrDY,EAAajB,GAAWA,EAAQiB,gBAAcC,EAC9CC,GAAc,EAGuB,QAAjCV,EAAMH,EAAYc,KAAKr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ShE,EAAQQ,MAAMe,WACrC2B,EAA6B,OAAf2B,IAAwB7E,EAAQmD,MAAQnD,EAAQQ,MAAMe,SAC1EvB,EAAU0E,GAAe9C,EAAMqB,KAAKC,GACpCwB,EAAc,MAETE,IACC5E,EAAQmD,OC5CpB,SAAsB2B,EAAaf,WAC7BxC,EAAQwC,EACLxC,OACLA,EAAQA,EAAMyC,UACAc,SACL,SAGJ,EDoCoBC,CAAaf,EAAQhE,EAAQQ,MAAMe,eACtDmD,EAAc1E,EACP,QAIPA,EAAQmD,KAAM,KACV6B,EAAQ,IAAIC,MAAM,yBACxBD,EAAME,OAAS,IACTF,EAGRL,mBAAsBR,KAAYnE,EAAQQ,WAEpC2E,EAASb,EAAQK,EAAgB3E,EAAQQ,MAAMiD,eACjD0B,MAAAA,EACKA,EAEFlC,EAAK2B,EAAQZ,EAAQmB,GAG9BhB,EAAQlB,KAAOA,aAGNA,GAAK,EAAMuB,KAAKC,MACvB,MAAOO,MACHR,KAAKY,oBACAZ,KAAKY,aAAaJ,EAAOL,SAE5BK,kBAnEEK,EAAQ9H,eAAAA,IAAAA,EAAU,KACvB8H,GAA4B,iBAAXA,QACd,IAAI3E,UAAU,uBAGjBiC,QAAUpF,EAAQoF,SAAW,QAC7ByC,aAAe7H,EAAQ6H,kBACvBlB,aAAe3G,EAAQ2G,cAAgBA,OACvCC,uBAAYmB,OAAQd,MAASjH,EAAQ4G,cACrCM,KAAOxE,MAAMQ,QAAQ4E,GAAU,CAAEhH,KAAM,GAAI+E,SAAUiC,EAAQrB,OAAQ,MAASqB,OAC9EZ,KAAKT,OAAS,YA8DvBK,EAAoB3G,aAAeA"} \ No newline at end of file +{"version":3,"file":"universal-router-sync.min.js","sources":["../node_modules/path-to-regexp/index.js","src/matchPath.js","src/matchRoute.js","src/resolveRoute.js","src/UniversalRouterSync.js","src/isChildRoute.js"],"sourcesContent":["/**\n * Expose `pathToRegexp`.\n */\nmodule.exports = pathToRegexp\nmodule.exports.parse = parse\nmodule.exports.compile = compile\nmodule.exports.tokensToFunction = tokensToFunction\nmodule.exports.tokensToRegExp = tokensToRegExp\n\n/**\n * Default configs.\n */\nvar DEFAULT_DELIMITER = '/'\n\n/**\n * The main path matching regexp utility.\n *\n * @type {RegExp}\n */\nvar PATH_REGEXP = new RegExp([\n // Match escaped characters that would otherwise appear in future matches.\n // This allows the user to escape special characters that won't transform.\n '(\\\\\\\\.)',\n // Match Express-style parameters and un-named parameters with a prefix\n // and optional suffixes. Matches appear as:\n //\n // \":test(\\\\d+)?\" => [\"test\", \"\\d+\", undefined, \"?\"]\n // \"(\\\\d+)\" => [undefined, undefined, \"\\d+\", undefined]\n '(?:\\\\:(\\\\w+)(?:\\\\(((?:\\\\\\\\.|[^\\\\\\\\()])+)\\\\))?|\\\\(((?:\\\\\\\\.|[^\\\\\\\\()])+)\\\\))([+*?])?'\n].join('|'), 'g')\n\n/**\n * Parse a string for the raw tokens.\n *\n * @param {string} str\n * @param {Object=} options\n * @return {!Array}\n */\nfunction parse (str, options) {\n var tokens = []\n var key = 0\n var index = 0\n var path = ''\n var defaultDelimiter = (options && options.delimiter) || DEFAULT_DELIMITER\n var whitelist = (options && options.whitelist) || undefined\n var pathEscaped = false\n var res\n\n while ((res = PATH_REGEXP.exec(str)) !== null) {\n var m = res[0]\n var escaped = res[1]\n var offset = res.index\n path += str.slice(index, offset)\n index = offset + m.length\n\n // Ignore already escaped sequences.\n if (escaped) {\n path += escaped[1]\n pathEscaped = true\n continue\n }\n\n var prev = ''\n var name = res[2]\n var capture = res[3]\n var group = res[4]\n var modifier = res[5]\n\n if (!pathEscaped && path.length) {\n var k = path.length - 1\n var c = path[k]\n var matches = whitelist ? whitelist.indexOf(c) > -1 : true\n\n if (matches) {\n prev = c\n path = path.slice(0, k)\n }\n }\n\n // Push the current path onto the tokens.\n if (path) {\n tokens.push(path)\n path = ''\n pathEscaped = false\n }\n\n var repeat = modifier === '+' || modifier === '*'\n var optional = modifier === '?' || modifier === '*'\n var pattern = capture || group\n var delimiter = prev || defaultDelimiter\n\n tokens.push({\n name: name || key++,\n prefix: prev,\n delimiter: delimiter,\n optional: optional,\n repeat: repeat,\n pattern: pattern\n ? escapeGroup(pattern)\n : '[^' + escapeString(delimiter === defaultDelimiter ? delimiter : (delimiter + defaultDelimiter)) + ']+?'\n })\n }\n\n // Push any remaining characters.\n if (path || index < str.length) {\n tokens.push(path + str.substr(index))\n }\n\n return tokens\n}\n\n/**\n * Compile a string to a template function for the path.\n *\n * @param {string} str\n * @param {Object=} options\n * @return {!function(Object=, Object=)}\n */\nfunction compile (str, options) {\n return tokensToFunction(parse(str, options), options)\n}\n\n/**\n * Expose a method for transforming tokens into the path function.\n */\nfunction tokensToFunction (tokens, options) {\n // Compile all the tokens into regexps.\n var matches = new Array(tokens.length)\n\n // Compile all the patterns before compilation.\n for (var i = 0; i < tokens.length; i++) {\n if (typeof tokens[i] === 'object') {\n matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$', flags(options))\n }\n }\n\n return function (data, options) {\n var path = ''\n var encode = (options && options.encode) || encodeURIComponent\n var validate = options ? options.validate !== false : true\n\n for (var i = 0; i < tokens.length; i++) {\n var token = tokens[i]\n\n if (typeof token === 'string') {\n path += token\n continue\n }\n\n var value = data ? data[token.name] : undefined\n var segment\n\n if (Array.isArray(value)) {\n if (!token.repeat) {\n throw new TypeError('Expected \"' + token.name + '\" to not repeat, but got array')\n }\n\n if (value.length === 0) {\n if (token.optional) continue\n\n throw new TypeError('Expected \"' + token.name + '\" to not be empty')\n }\n\n for (var j = 0; j < value.length; j++) {\n segment = encode(value[j], token)\n\n if (validate && !matches[i].test(segment)) {\n throw new TypeError('Expected all \"' + token.name + '\" to match \"' + token.pattern + '\"')\n }\n\n path += (j === 0 ? token.prefix : token.delimiter) + segment\n }\n\n continue\n }\n\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\n segment = encode(String(value), token)\n\n if (validate && !matches[i].test(segment)) {\n throw new TypeError('Expected \"' + token.name + '\" to match \"' + token.pattern + '\", but got \"' + segment + '\"')\n }\n\n path += token.prefix + segment\n continue\n }\n\n if (token.optional) continue\n\n throw new TypeError('Expected \"' + token.name + '\" to be ' + (token.repeat ? 'an array' : 'a string'))\n }\n\n return path\n }\n}\n\n/**\n * Escape a regular expression string.\n *\n * @param {string} str\n * @return {string}\n */\nfunction escapeString (str) {\n return str.replace(/([.+*?=^!:${}()[\\]|/\\\\])/g, '\\\\$1')\n}\n\n/**\n * Escape the capturing group by escaping special characters and meaning.\n *\n * @param {string} group\n * @return {string}\n */\nfunction escapeGroup (group) {\n return group.replace(/([=!:$/()])/g, '\\\\$1')\n}\n\n/**\n * Get the flags for a regexp from the options.\n *\n * @param {Object} options\n * @return {string}\n */\nfunction flags (options) {\n return options && options.sensitive ? '' : 'i'\n}\n\n/**\n * Pull out keys from a regexp.\n *\n * @param {!RegExp} path\n * @param {Array=} keys\n * @return {!RegExp}\n */\nfunction regexpToRegexp (path, keys) {\n if (!keys) return path\n\n // Use a negative lookahead to match only capturing groups.\n var groups = path.source.match(/\\((?!\\?)/g)\n\n if (groups) {\n for (var i = 0; i < groups.length; i++) {\n keys.push({\n name: i,\n prefix: null,\n delimiter: null,\n optional: false,\n repeat: false,\n pattern: null\n })\n }\n }\n\n return path\n}\n\n/**\n * Transform an array into a regexp.\n *\n * @param {!Array} path\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction arrayToRegexp (path, keys, options) {\n var parts = []\n\n for (var i = 0; i < path.length; i++) {\n parts.push(pathToRegexp(path[i], keys, options).source)\n }\n\n return new RegExp('(?:' + parts.join('|') + ')', flags(options))\n}\n\n/**\n * Create a path regexp from string input.\n *\n * @param {string} path\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction stringToRegexp (path, keys, options) {\n return tokensToRegExp(parse(path, options), keys, options)\n}\n\n/**\n * Expose a function for taking tokens and returning a RegExp.\n *\n * @param {!Array} tokens\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction tokensToRegExp (tokens, keys, options) {\n options = options || {}\n\n var strict = options.strict\n var start = options.start !== false\n var end = options.end !== false\n var delimiter = options.delimiter || DEFAULT_DELIMITER\n var endsWith = [].concat(options.endsWith || []).map(escapeString).concat('$').join('|')\n var route = start ? '^' : ''\n\n // Iterate over the tokens and create our regexp string.\n for (var i = 0; i < tokens.length; i++) {\n var token = tokens[i]\n\n if (typeof token === 'string') {\n route += escapeString(token)\n } else {\n var capture = token.repeat\n ? '(?:' + token.pattern + ')(?:' + escapeString(token.delimiter) + '(?:' + token.pattern + '))*'\n : token.pattern\n\n if (keys) keys.push(token)\n\n if (token.optional) {\n if (!token.prefix) {\n route += '(' + capture + ')?'\n } else {\n route += '(?:' + escapeString(token.prefix) + '(' + capture + '))?'\n }\n } else {\n route += escapeString(token.prefix) + '(' + capture + ')'\n }\n }\n }\n\n if (end) {\n if (!strict) route += '(?:' + escapeString(delimiter) + ')?'\n\n route += endsWith === '$' ? '$' : '(?=' + endsWith + ')'\n } else {\n var endToken = tokens[tokens.length - 1]\n var isEndDelimited = typeof endToken === 'string'\n ? endToken[endToken.length - 1] === delimiter\n : endToken === undefined\n\n if (!strict) route += '(?:' + escapeString(delimiter) + '(?=' + endsWith + '))?'\n if (!isEndDelimited) route += '(?=' + escapeString(delimiter) + '|' + endsWith + ')'\n }\n\n return new RegExp(route, flags(options))\n}\n\n/**\n * Normalize the given path string, returning a regular expression.\n *\n * An empty array can be passed in for the keys, which will hold the\n * placeholder key descriptions. For example, using `/user/:id`, `keys` will\n * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.\n *\n * @param {(string|RegExp|Array)} path\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction pathToRegexp (path, keys, options) {\n if (path instanceof RegExp) {\n return regexpToRegexp(path, keys)\n }\n\n if (Array.isArray(path)) {\n return arrayToRegexp(/** @type {!Array} */ (path), keys, options)\n }\n\n return stringToRegexp(/** @type {string} */ (path), keys, options)\n}\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nimport pathToRegexp from 'path-to-regexp'\n\nconst { hasOwnProperty } = Object.prototype\nconst cache = new Map()\n\nfunction decodeParam(val) {\n try {\n return decodeURIComponent(val)\n } catch (err) {\n return val\n }\n}\n\nfunction matchPath(route, pathname, parentKeys, parentParams) {\n const end = !route.children\n const cacheKey = `${route.path || ''}|${end}`\n let regexp = cache.get(cacheKey)\n\n if (!regexp) {\n const keys = []\n regexp = {\n keys,\n pattern: pathToRegexp(route.path || '', keys, { end }),\n }\n cache.set(cacheKey, regexp)\n }\n\n const m = regexp.pattern.exec(pathname)\n if (!m) {\n return null\n }\n\n const path = m[0]\n const params = { ...parentParams }\n\n for (let i = 1; i < m.length; i++) {\n const key = regexp.keys[i - 1]\n const prop = key.name\n const value = m[i]\n if (value !== undefined || !hasOwnProperty.call(params, prop)) {\n if (key.repeat) {\n params[prop] = value ? value.split(key.delimiter).map(decodeParam) : []\n } else {\n params[prop] = value ? decodeParam(value) : value\n }\n }\n }\n\n return {\n path: !end && path.charAt(path.length - 1) === '/' ? path.substr(1) : path,\n keys: parentKeys.concat(regexp.keys),\n params,\n }\n}\n\nexport default matchPath\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nimport matchPath from './matchPath'\n\nfunction matchRoute(route, baseUrl, pathname, parentKeys, parentParams) {\n let match\n let childMatches\n let childIndex = 0\n\n return {\n next(routeToSkip) {\n if (route === routeToSkip) {\n return { done: true }\n }\n\n if (!match) {\n match = matchPath(route, pathname, parentKeys, parentParams)\n\n if (match) {\n return {\n done: false,\n value: {\n route,\n baseUrl,\n path: match.path,\n keys: match.keys,\n params: match.params,\n },\n }\n }\n }\n\n if (match && route.children) {\n while (childIndex < route.children.length) {\n if (!childMatches) {\n const childRoute = route.children[childIndex]\n childRoute.parent = route\n\n childMatches = matchRoute(\n childRoute,\n baseUrl + match.path,\n pathname.substr(match.path.length),\n match.keys,\n match.params,\n )\n }\n\n const childMatch = childMatches.next(routeToSkip)\n if (!childMatch.done) {\n return {\n done: false,\n value: childMatch.value,\n }\n }\n\n childMatches = null\n childIndex++\n }\n }\n\n return { done: true }\n },\n }\n}\n\nexport default matchRoute\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nfunction resolveRoute(context, params) {\n if (typeof context.route.action === 'function') {\n return context.route.action(context, params)\n }\n return undefined\n}\n\nexport default resolveRoute\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nimport pathToRegexp from 'path-to-regexp'\nimport matchRoute from './matchRoute'\nimport resolveRoute from './resolveRoute'\nimport isChildRoute from './isChildRoute'\n\nclass UniversalRouterSync {\n constructor(routes, options = {}) {\n if (!routes || typeof routes !== 'object') {\n throw new TypeError('Invalid routes')\n }\n\n this.baseUrl = options.baseUrl || ''\n this.errorHandler = options.errorHandler\n this.resolveRoute = options.resolveRoute || resolveRoute\n this.context = { router: this, ...options.context }\n this.root = Array.isArray(routes) ? { path: '', children: routes, parent: null } : routes\n this.root.parent = null\n }\n\n resolve(pathnameOrContext) {\n const context = {\n ...this.context,\n ...(typeof pathnameOrContext === 'string'\n ? { pathname: pathnameOrContext }\n : pathnameOrContext),\n }\n const match = matchRoute(\n this.root,\n this.baseUrl,\n context.pathname.substr(this.baseUrl.length),\n [],\n null,\n )\n const resolve = this.resolveRoute\n let matches = null\n let nextMatches = null\n let currentContext = context\n\n function next(resume, parent = matches.value.route, prevResult) {\n const routeToSkip = prevResult === null && !matches.done && matches.value.route\n matches = nextMatches || match.next(routeToSkip)\n nextMatches = null\n\n if (!resume) {\n if (matches.done || !isChildRoute(parent, matches.value.route)) {\n nextMatches = matches\n return null\n }\n }\n\n if (matches.done) {\n const error = new Error('Route not found')\n error.status = 404\n throw error\n }\n\n currentContext = { ...context, ...matches.value }\n\n const result = resolve(currentContext, matches.value.params)\n if (result !== null && result !== undefined) {\n return result\n }\n return next(resume, parent, result)\n }\n\n context.next = next\n\n try {\n return next(true, this.root)\n } catch (error) {\n if (this.errorHandler) {\n return this.errorHandler(error, currentContext)\n }\n throw error\n }\n }\n}\n\nUniversalRouterSync.pathToRegexp = pathToRegexp\n\nexport default UniversalRouterSync\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nfunction isChildRoute(parentRoute, childRoute) {\n let route = childRoute\n while (route) {\n route = route.parent\n if (route === parentRoute) {\n return true\n }\n }\n return false\n}\n\nexport default isChildRoute\n"],"names":["str","options","tokensToFunction","parse","pathToRegexp","tokensToRegExp","DEFAULT_DELIMITER","PATH_REGEXP","RegExp","join","res","group","tokens","key","index","path","defaultDelimiter","delimiter","whitelist","undefined","pathEscaped","exec","m","escaped","offset","slice","length","prev","name","capture","modifier","k","c","indexOf","push","repeat","optional","pattern","prefix","replace","escapeString","substr","matches","Array","i","flags","data","encode","encodeURIComponent","validate","token","segment","value","isArray","TypeError","j","test","String","sensitive","keys","strict","start","end","endsWith","concat","map","route","endToken","isEndDelimited","groups","source","match","regexpToRegexp","parts","arrayToRegexp","stringToRegexp","hasOwnProperty","Object","prototype","cache","Map","decodeParam","val","decodeURIComponent","err","matchRoute","baseUrl","pathname","parentKeys","parentParams","childMatches","childIndex","next","routeToSkip","done","children","cacheKey","regexp","get","set","params","prop","call","split","charAt","matchPath","childRoute","parent","childMatch","resolveRoute","context","action","UniversalRouterSync","resolve","pathnameOrContext","this","root","nextMatches","currentContext","resume","prevResult","parentRoute","isChildRoute","error","Error","status","result","errorHandler","routes","router"],"mappings":";yMAsHA,WAAkBA,EAAKC,UACdC,EAAiBC,EAAMH,EAAKC,GAAUA,GApH/C,MAAiBG,IACMD,IAEWD,IACFG,EAK5BC,EAAoB,IAOpBC,EAAc,IAAIC,OAAO,CAG3B,UAMA,uFACAC,KAAK,KAAM,KASb,SAASN,EAAOH,EAAKC,WAQfS,EAsKgBC,EA7KhBC,EAAS,GACTC,EAAM,EACNC,EAAQ,EACRC,EAAO,GACPC,EAAoBf,GAAWA,EAAQgB,WAAcX,EACrDY,EAAajB,GAAWA,EAAQiB,gBAAcC,EAC9CC,GAAc,EAGuB,QAAjCV,EAAMH,EAAYc,KAAKrB,KAAgB,KACzCsB,EAAIZ,EAAI,GACRa,EAAUb,EAAI,GACdc,EAASd,EAAII,SACjBC,GAAQf,EAAIyB,MAAMX,EAAOU,GACzBV,EAAQU,EAASF,EAAEI,OAGfH,EACFR,GAAQQ,EAAQ,GAChBH,GAAc,WAIZO,EAAO,GACPC,EAAOlB,EAAI,GACXmB,EAAUnB,EAAI,GACdC,EAAQD,EAAI,GACZoB,EAAWpB,EAAI,OAEdU,GAAeL,EAAKW,OAAQ,KAC3BK,EAAIhB,EAAKW,OAAS,EAClBM,EAAIjB,EAAKgB,KACCb,IAAoC,EAAxBA,EAAUe,QAAQD,MAG1CL,EAAOK,EACPjB,EAAOA,EAAKU,MAAM,EAAGM,IAKrBhB,IACFH,EAAOsB,KAAKnB,GACZA,EAAO,GACPK,GAAc,OAGZe,EAAsB,MAAbL,GAAiC,MAAbA,EAC7BM,EAAwB,MAAbN,GAAiC,MAAbA,EAC/BO,EAAUR,GAAWlB,EACrBM,EAAYU,GAAQX,EAExBJ,EAAOsB,KAAK,CACVN,KAAMA,GAAQf,IACdyB,OAAQX,EACRV,UAAWA,EACXmB,SAAUA,EACVD,OAAQA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AAOL,SAE5BK,kBAnEEK,EAAQ/H,eAAAA,IAAAA,EAAU,KACvB+H,GAA4B,iBAAXA,QACd,IAAI1E,UAAU,uBAGjBgC,QAAUrF,EAAQqF,SAAW,QAC7ByC,aAAe9H,EAAQ8H,kBACvBlB,aAAe5G,EAAQ4G,cAAgBA,OACvCC,uBAAYmB,OAAQd,MAASlH,EAAQ6G,cACrCM,KAAOzE,MAAMU,QAAQ2E,GAAU,CAAEjH,KAAM,GAAIgF,SAAUiC,EAAQrB,OAAQ,MAASqB,OAC9EZ,KAAKT,OAAS,YA8DvBK,EAAoB5G,aAAeA"} \ No newline at end of file diff --git a/dist/universal-router.js b/dist/universal-router.js index 140b270..a7802e9 100644 --- a/dist/universal-router.js +++ b/dist/universal-router.js @@ -82,21 +82,22 @@ } function compile(str, options) { - return tokensToFunction(parse(str, options)); + return tokensToFunction(parse(str, options), options); } - function tokensToFunction(tokens) { + function tokensToFunction(tokens, options) { var matches = new Array(tokens.length); for (var i = 0; i < tokens.length; i++) { if (typeof tokens[i] === 'object') { - matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$'); + matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$', flags(options)); } } return function (data, options) { var path = ''; var encode = options && options.encode || encodeURIComponent; + var validate = options ? options.validate !== false : true; for (var i = 0; i < tokens.length; i++) { var token = tokens[i]; @@ -122,7 +123,7 @@ for (var j = 0; j < value.length; j++) { segment = encode(value[j], token); - if (!matches[i].test(segment)) { + if (validate && !matches[i].test(segment)) { throw new TypeError('Expected all "' + token.name + '" to match "' + token.pattern + '"'); } @@ -135,7 +136,7 @@ if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') { segment = encode(String(value), token); - if (!matches[i].test(segment)) { + if (validate && !matches[i].test(segment)) { throw new TypeError('Expected "' + token.name + '" to match "' + token.pattern + '", but got "' + segment + '"'); } diff --git a/dist/universal-router.js.map b/dist/universal-router.js.map index 02cea0a..488b451 100644 --- a/dist/universal-router.js.map +++ b/dist/universal-router.js.map @@ -1 +1 @@ -{"version":3,"file":"universal-router.js","sources":["../node_modules/path-to-regexp/index.js","src/matchPath.js","src/matchRoute.js","src/resolveRoute.js","src/isChildRoute.js","src/UniversalRouter.js"],"sourcesContent":["/**\n * Expose `pathToRegexp`.\n */\nmodule.exports = pathToRegexp\nmodule.exports.parse = parse\nmodule.exports.compile = compile\nmodule.exports.tokensToFunction = tokensToFunction\nmodule.exports.tokensToRegExp = tokensToRegExp\n\n/**\n * Default configs.\n */\nvar DEFAULT_DELIMITER = '/'\n\n/**\n * The main path matching regexp utility.\n *\n * @type {RegExp}\n */\nvar PATH_REGEXP = new RegExp([\n // Match escaped characters that would otherwise appear in future matches.\n // This allows the user to escape special characters that won't transform.\n '(\\\\\\\\.)',\n // Match Express-style parameters and un-named parameters with a prefix\n // and optional suffixes. Matches appear as:\n //\n // \":test(\\\\d+)?\" => [\"test\", \"\\d+\", undefined, \"?\"]\n // \"(\\\\d+)\" => [undefined, undefined, \"\\d+\", undefined]\n '(?:\\\\:(\\\\w+)(?:\\\\(((?:\\\\\\\\.|[^\\\\\\\\()])+)\\\\))?|\\\\(((?:\\\\\\\\.|[^\\\\\\\\()])+)\\\\))([+*?])?'\n].join('|'), 'g')\n\n/**\n * Parse a string for the raw tokens.\n *\n * @param {string} str\n * @param {Object=} options\n * @return {!Array}\n */\nfunction parse (str, options) {\n var tokens = []\n var key = 0\n var index = 0\n var path = ''\n var defaultDelimiter = (options && options.delimiter) || DEFAULT_DELIMITER\n var whitelist = (options && options.whitelist) || undefined\n var pathEscaped = false\n var res\n\n while ((res = PATH_REGEXP.exec(str)) !== null) {\n var m = res[0]\n var escaped = res[1]\n var offset = res.index\n path += str.slice(index, offset)\n index = offset + m.length\n\n // Ignore already escaped sequences.\n if (escaped) {\n path += escaped[1]\n pathEscaped = true\n continue\n }\n\n var prev = ''\n var name = res[2]\n var capture = res[3]\n var group = res[4]\n var modifier = res[5]\n\n if (!pathEscaped && path.length) {\n var k = path.length - 1\n var c = path[k]\n var matches = whitelist ? whitelist.indexOf(c) > -1 : true\n\n if (matches) {\n prev = c\n path = path.slice(0, k)\n }\n }\n\n // Push the current path onto the tokens.\n if (path) {\n tokens.push(path)\n path = ''\n pathEscaped = false\n }\n\n var repeat = modifier === '+' || modifier === '*'\n var optional = modifier === '?' || modifier === '*'\n var pattern = capture || group\n var delimiter = prev || defaultDelimiter\n\n tokens.push({\n name: name || key++,\n prefix: prev,\n delimiter: delimiter,\n optional: optional,\n repeat: repeat,\n pattern: pattern\n ? escapeGroup(pattern)\n : '[^' + escapeString(delimiter === defaultDelimiter ? delimiter : (delimiter + defaultDelimiter)) + ']+?'\n })\n }\n\n // Push any remaining characters.\n if (path || index < str.length) {\n tokens.push(path + str.substr(index))\n }\n\n return tokens\n}\n\n/**\n * Compile a string to a template function for the path.\n *\n * @param {string} str\n * @param {Object=} options\n * @return {!function(Object=, Object=)}\n */\nfunction compile (str, options) {\n return tokensToFunction(parse(str, options))\n}\n\n/**\n * Expose a method for transforming tokens into the path function.\n */\nfunction tokensToFunction (tokens) {\n // Compile all the tokens into regexps.\n var matches = new Array(tokens.length)\n\n // Compile all the patterns before compilation.\n for (var i = 0; i < tokens.length; i++) {\n if (typeof tokens[i] === 'object') {\n matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$')\n }\n }\n\n return function (data, options) {\n var path = ''\n var encode = (options && options.encode) || encodeURIComponent\n\n for (var i = 0; i < tokens.length; i++) {\n var token = tokens[i]\n\n if (typeof token === 'string') {\n path += token\n continue\n }\n\n var value = data ? data[token.name] : undefined\n var segment\n\n if (Array.isArray(value)) {\n if (!token.repeat) {\n throw new TypeError('Expected \"' + token.name + '\" to not repeat, but got array')\n }\n\n if (value.length === 0) {\n if (token.optional) continue\n\n throw new TypeError('Expected \"' + token.name + '\" to not be empty')\n }\n\n for (var j = 0; j < value.length; j++) {\n segment = encode(value[j], token)\n\n if (!matches[i].test(segment)) {\n throw new TypeError('Expected all \"' + token.name + '\" to match \"' + token.pattern + '\"')\n }\n\n path += (j === 0 ? token.prefix : token.delimiter) + segment\n }\n\n continue\n }\n\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\n segment = encode(String(value), token)\n\n if (!matches[i].test(segment)) {\n throw new TypeError('Expected \"' + token.name + '\" to match \"' + token.pattern + '\", but got \"' + segment + '\"')\n }\n\n path += token.prefix + segment\n continue\n }\n\n if (token.optional) continue\n\n throw new TypeError('Expected \"' + token.name + '\" to be ' + (token.repeat ? 'an array' : 'a string'))\n }\n\n return path\n }\n}\n\n/**\n * Escape a regular expression string.\n *\n * @param {string} str\n * @return {string}\n */\nfunction escapeString (str) {\n return str.replace(/([.+*?=^!:${}()[\\]|/\\\\])/g, '\\\\$1')\n}\n\n/**\n * Escape the capturing group by escaping special characters and meaning.\n *\n * @param {string} group\n * @return {string}\n */\nfunction escapeGroup (group) {\n return group.replace(/([=!:$/()])/g, '\\\\$1')\n}\n\n/**\n * Get the flags for a regexp from the options.\n *\n * @param {Object} options\n * @return {string}\n */\nfunction flags (options) {\n return options && options.sensitive ? '' : 'i'\n}\n\n/**\n * Pull out keys from a regexp.\n *\n * @param {!RegExp} path\n * @param {Array=} keys\n * @return {!RegExp}\n */\nfunction regexpToRegexp (path, keys) {\n if (!keys) return path\n\n // Use a negative lookahead to match only capturing groups.\n var groups = path.source.match(/\\((?!\\?)/g)\n\n if (groups) {\n for (var i = 0; i < groups.length; i++) {\n keys.push({\n name: i,\n prefix: null,\n delimiter: null,\n optional: false,\n repeat: false,\n pattern: null\n })\n }\n }\n\n return path\n}\n\n/**\n * Transform an array into a regexp.\n *\n * @param {!Array} path\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction arrayToRegexp (path, keys, options) {\n var parts = []\n\n for (var i = 0; i < path.length; i++) {\n parts.push(pathToRegexp(path[i], keys, options).source)\n }\n\n return new RegExp('(?:' + parts.join('|') + ')', flags(options))\n}\n\n/**\n * Create a path regexp from string input.\n *\n * @param {string} path\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction stringToRegexp (path, keys, options) {\n return tokensToRegExp(parse(path, options), keys, options)\n}\n\n/**\n * Expose a function for taking tokens and returning a RegExp.\n *\n * @param {!Array} tokens\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction tokensToRegExp (tokens, keys, options) {\n options = options || {}\n\n var strict = options.strict\n var start = options.start !== false\n var end = options.end !== false\n var delimiter = options.delimiter || DEFAULT_DELIMITER\n var endsWith = [].concat(options.endsWith || []).map(escapeString).concat('$').join('|')\n var route = start ? '^' : ''\n\n // Iterate over the tokens and create our regexp string.\n for (var i = 0; i < tokens.length; i++) {\n var token = tokens[i]\n\n if (typeof token === 'string') {\n route += escapeString(token)\n } else {\n var capture = token.repeat\n ? '(?:' + token.pattern + ')(?:' + escapeString(token.delimiter) + '(?:' + token.pattern + '))*'\n : token.pattern\n\n if (keys) keys.push(token)\n\n if (token.optional) {\n if (!token.prefix) {\n route += '(' + capture + ')?'\n } else {\n route += '(?:' + escapeString(token.prefix) + '(' + capture + '))?'\n }\n } else {\n route += escapeString(token.prefix) + '(' + capture + ')'\n }\n }\n }\n\n if (end) {\n if (!strict) route += '(?:' + escapeString(delimiter) + ')?'\n\n route += endsWith === '$' ? '$' : '(?=' + endsWith + ')'\n } else {\n var endToken = tokens[tokens.length - 1]\n var isEndDelimited = typeof endToken === 'string'\n ? endToken[endToken.length - 1] === delimiter\n : endToken === undefined\n\n if (!strict) route += '(?:' + escapeString(delimiter) + '(?=' + endsWith + '))?'\n if (!isEndDelimited) route += '(?=' + escapeString(delimiter) + '|' + endsWith + ')'\n }\n\n return new RegExp(route, flags(options))\n}\n\n/**\n * Normalize the given path string, returning a regular expression.\n *\n * An empty array can be passed in for the keys, which will hold the\n * placeholder key descriptions. For example, using `/user/:id`, `keys` will\n * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.\n *\n * @param {(string|RegExp|Array)} path\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction pathToRegexp (path, keys, options) {\n if (path instanceof RegExp) {\n return regexpToRegexp(path, keys)\n }\n\n if (Array.isArray(path)) {\n return arrayToRegexp(/** @type {!Array} */ (path), keys, options)\n }\n\n return stringToRegexp(/** @type {string} */ (path), keys, options)\n}\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nimport pathToRegexp from 'path-to-regexp'\n\nconst { hasOwnProperty } = Object.prototype\nconst cache = new Map()\n\nfunction decodeParam(val) {\n try {\n return decodeURIComponent(val)\n } catch (err) {\n return val\n }\n}\n\nfunction matchPath(route, pathname, parentKeys, parentParams) {\n const end = !route.children\n const cacheKey = `${route.path || ''}|${end}`\n let regexp = cache.get(cacheKey)\n\n if (!regexp) {\n const keys = []\n regexp = {\n keys,\n pattern: pathToRegexp(route.path || '', keys, { end }),\n }\n cache.set(cacheKey, regexp)\n }\n\n const m = regexp.pattern.exec(pathname)\n if (!m) {\n return null\n }\n\n const path = m[0]\n const params = { ...parentParams }\n\n for (let i = 1; i < m.length; i++) {\n const key = regexp.keys[i - 1]\n const prop = key.name\n const value = m[i]\n if (value !== undefined || !hasOwnProperty.call(params, prop)) {\n if (key.repeat) {\n params[prop] = value ? value.split(key.delimiter).map(decodeParam) : []\n } else {\n params[prop] = value ? decodeParam(value) : value\n }\n }\n }\n\n return {\n path: !end && path.charAt(path.length - 1) === '/' ? path.substr(1) : path,\n keys: parentKeys.concat(regexp.keys),\n params,\n }\n}\n\nexport default matchPath\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nimport matchPath from './matchPath'\n\nfunction matchRoute(route, baseUrl, pathname, parentKeys, parentParams) {\n let match\n let childMatches\n let childIndex = 0\n\n return {\n next(routeToSkip) {\n if (route === routeToSkip) {\n return { done: true }\n }\n\n if (!match) {\n match = matchPath(route, pathname, parentKeys, parentParams)\n\n if (match) {\n return {\n done: false,\n value: {\n route,\n baseUrl,\n path: match.path,\n keys: match.keys,\n params: match.params,\n },\n }\n }\n }\n\n if (match && route.children) {\n while (childIndex < route.children.length) {\n if (!childMatches) {\n const childRoute = route.children[childIndex]\n childRoute.parent = route\n\n childMatches = matchRoute(\n childRoute,\n baseUrl + match.path,\n pathname.substr(match.path.length),\n match.keys,\n match.params,\n )\n }\n\n const childMatch = childMatches.next(routeToSkip)\n if (!childMatch.done) {\n return {\n done: false,\n value: childMatch.value,\n }\n }\n\n childMatches = null\n childIndex++\n }\n }\n\n return { done: true }\n },\n }\n}\n\nexport default matchRoute\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nfunction resolveRoute(context, params) {\n if (typeof context.route.action === 'function') {\n return context.route.action(context, params)\n }\n return undefined\n}\n\nexport default resolveRoute\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nfunction isChildRoute(parentRoute, childRoute) {\n let route = childRoute\n while (route) {\n route = route.parent\n if (route === parentRoute) {\n return true\n }\n }\n return false\n}\n\nexport default isChildRoute\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nimport pathToRegexp from 'path-to-regexp'\nimport matchRoute from './matchRoute'\nimport resolveRoute from './resolveRoute'\nimport isChildRoute from './isChildRoute'\n\nclass UniversalRouter {\n constructor(routes, options = {}) {\n if (!routes || typeof routes !== 'object') {\n throw new TypeError('Invalid routes')\n }\n\n this.baseUrl = options.baseUrl || ''\n this.errorHandler = options.errorHandler\n this.resolveRoute = options.resolveRoute || resolveRoute\n this.context = { router: this, ...options.context }\n this.root = Array.isArray(routes) ? { path: '', children: routes, parent: null } : routes\n this.root.parent = null\n }\n\n resolve(pathnameOrContext) {\n const context = {\n ...this.context,\n ...(typeof pathnameOrContext === 'string'\n ? { pathname: pathnameOrContext }\n : pathnameOrContext),\n }\n const match = matchRoute(\n this.root,\n this.baseUrl,\n context.pathname.substr(this.baseUrl.length),\n [],\n null,\n )\n const resolve = this.resolveRoute\n let matches = null\n let nextMatches = null\n let currentContext = context\n\n function next(resume, parent = matches.value.route, prevResult) {\n const routeToSkip = prevResult === null && !matches.done && matches.value.route\n matches = nextMatches || match.next(routeToSkip)\n nextMatches = null\n\n if (!resume) {\n if (matches.done || !isChildRoute(parent, matches.value.route)) {\n nextMatches = matches\n return Promise.resolve(null)\n }\n }\n\n if (matches.done) {\n const error = new Error('Route not found')\n error.status = 404\n return Promise.reject(error)\n }\n\n currentContext = { ...context, ...matches.value }\n\n return Promise.resolve(resolve(currentContext, matches.value.params)).then((result) => {\n if (result !== null && result !== undefined) {\n return result\n }\n return next(resume, parent, result)\n })\n }\n\n context.next = next\n\n return Promise.resolve()\n .then(() => next(true, this.root))\n .catch((error) => {\n if (this.errorHandler) {\n return this.errorHandler(error, currentContext)\n }\n throw error\n })\n }\n}\n\nUniversalRouter.pathToRegexp = pathToRegexp\n\nexport default UniversalRouter\n"],"names":["pathToRegexp","parse","compile","tokensToFunction","tokensToRegExp","DEFAULT_DELIMITER","PATH_REGEXP","RegExp","join","str","options","tokens","key","index","path","defaultDelimiter","delimiter","whitelist","undefined","pathEscaped","res","exec","m","escaped","offset","slice","length","prev","name","capture","group","modifier","k","c","matches","indexOf","push","repeat","optional","pattern","prefix","escapeGroup","escapeString","substr","Array","i","data","encode","encodeURIComponent","token","value","segment","isArray","TypeError","j","test","String","replace","flags","sensitive","regexpToRegexp","keys","groups","source","match","arrayToRegexp","parts","stringToRegexp","strict","start","end","endsWith","concat","map","route","endToken","isEndDelimited","hasOwnProperty","Object","prototype","cache","Map","decodeParam","val","decodeURIComponent","err","matchPath","pathname","parentKeys","parentParams","children","cacheKey","regexp","get","set","params","prop","call","split","charAt","matchRoute","baseUrl","childMatches","childIndex","next","routeToSkip","done","childRoute","parent","childMatch","resolveRoute","context","action","isChildRoute","parentRoute","UniversalRouter","routes","errorHandler","router","root","resolve","pathnameOrContext","nextMatches","currentContext","resume","prevResult","Promise","error","Error","status","reject","then","result"],"mappings":";;;;;;;;EAGA,kBAAc,GAAGA,YAAjB;EACA,WAAoB,GAAGC,KAAvB;EACA,aAAsB,GAAGC,OAAzB;EACA,sBAA+B,GAAGC,gBAAlC;EACA,oBAA6B,GAAGC,cAAhC;EAKA,IAAIC,iBAAiB,GAAG,GAAxB;EAOA,IAAIC,WAAW,GAAG,IAAIC,MAAJ,CAAW,CAG3B,SAH2B,EAS3B,qFAT2B,EAU3BC,IAV2B,CAUtB,GAVsB,CAAX,EAUL,GAVK,CAAlB;;EAmBA,SAASP,KAAT,CAAgBQ,GAAhB,EAAqBC,OAArB,EAA8B;EAC5B,MAAIC,MAAM,GAAG,EAAb;EACA,MAAIC,GAAG,GAAG,CAAV;EACA,MAAIC,KAAK,GAAG,CAAZ;EACA,MAAIC,IAAI,GAAG,EAAX;EACA,MAAIC,gBAAgB,GAAIL,OAAO,IAAIA,OAAO,CAACM,SAApB,IAAkCX,iBAAzD;EACA,MAAIY,SAAS,GAAIP,OAAO,IAAIA,OAAO,CAACO,SAApB,IAAkCC,SAAlD;EACA,MAAIC,WAAW,GAAG,KAAlB;EACA,MAAIC,GAAJ;;EAEA,SAAO,CAACA,GAAG,GAAGd,WAAW,CAACe,IAAZ,CAAiBZ,GAAjB,CAAP,MAAkC,IAAzC,EAA+C;EAC7C,QAAIa,CAAC,GAAGF,GAAG,CAAC,CAAD,CAAX;EACA,QAAIG,OAAO,GAAGH,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AAOkH,MAAP;EACD;;EACD,eAAO5B,IAAI,CAACoB,MAAD,EAAShB,MAAT,EAAiBwB,MAAjB,CAAX;EACD,OALM,CAAP;EAMD;;EAEDrB,IAAAA,OAAO,CAACP,IAAR,GAAeA,IAAf;EAEA,WAAOsB,OAAO,CAACN,OAAR,GACJW,IADI,CACC;EAAA,aAAM3B,IAAI,CAAC,IAAD,EAAO,KAAI,CAACe,IAAZ,CAAV;EAAA,KADD,WAEE,UAACQ,KAAD,EAAW;EAChB,UAAI,KAAI,CAACV,YAAT,EAAuB;EACrB,eAAO,KAAI,CAACA,YAAL,CAAkBU,KAAlB,EAAyBJ,cAAzB,CAAP;EACD;;EACD,YAAMI,KAAN;EACD,KAPI,CAAP;EAQD;;;;;EAGHZ,eAAe,CAACnH,YAAhB,GAA+BA,cAA/B;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"universal-router.js","sources":["../node_modules/path-to-regexp/index.js","src/matchPath.js","src/matchRoute.js","src/resolveRoute.js","src/isChildRoute.js","src/UniversalRouter.js"],"sourcesContent":["/**\n * Expose `pathToRegexp`.\n */\nmodule.exports = pathToRegexp\nmodule.exports.parse = parse\nmodule.exports.compile = compile\nmodule.exports.tokensToFunction = tokensToFunction\nmodule.exports.tokensToRegExp = tokensToRegExp\n\n/**\n * Default configs.\n */\nvar DEFAULT_DELIMITER = '/'\n\n/**\n * The main path matching regexp utility.\n *\n * @type {RegExp}\n */\nvar PATH_REGEXP = new RegExp([\n // Match escaped characters that would otherwise appear in future matches.\n // This allows the user to escape special characters that won't transform.\n '(\\\\\\\\.)',\n // Match Express-style parameters and un-named parameters with a prefix\n // and optional suffixes. Matches appear as:\n //\n // \":test(\\\\d+)?\" => [\"test\", \"\\d+\", undefined, \"?\"]\n // \"(\\\\d+)\" => [undefined, undefined, \"\\d+\", undefined]\n '(?:\\\\:(\\\\w+)(?:\\\\(((?:\\\\\\\\.|[^\\\\\\\\()])+)\\\\))?|\\\\(((?:\\\\\\\\.|[^\\\\\\\\()])+)\\\\))([+*?])?'\n].join('|'), 'g')\n\n/**\n * Parse a string for the raw tokens.\n *\n * @param {string} str\n * @param {Object=} options\n * @return {!Array}\n */\nfunction parse (str, options) {\n var tokens = []\n var key = 0\n var index = 0\n var path = ''\n var defaultDelimiter = (options && options.delimiter) || DEFAULT_DELIMITER\n var whitelist = (options && options.whitelist) || undefined\n var pathEscaped = false\n var res\n\n while ((res = PATH_REGEXP.exec(str)) !== null) {\n var m = res[0]\n var escaped = res[1]\n var offset = res.index\n path += str.slice(index, offset)\n index = offset + m.length\n\n // Ignore already escaped sequences.\n if (escaped) {\n path += escaped[1]\n pathEscaped = true\n continue\n }\n\n var prev = ''\n var name = res[2]\n var capture = res[3]\n var group = res[4]\n var modifier = res[5]\n\n if (!pathEscaped && path.length) {\n var k = path.length - 1\n var c = path[k]\n var matches = whitelist ? whitelist.indexOf(c) > -1 : true\n\n if (matches) {\n prev = c\n path = path.slice(0, k)\n }\n }\n\n // Push the current path onto the tokens.\n if (path) {\n tokens.push(path)\n path = ''\n pathEscaped = false\n }\n\n var repeat = modifier === '+' || modifier === '*'\n var optional = modifier === '?' || modifier === '*'\n var pattern = capture || group\n var delimiter = prev || defaultDelimiter\n\n tokens.push({\n name: name || key++,\n prefix: prev,\n delimiter: delimiter,\n optional: optional,\n repeat: repeat,\n pattern: pattern\n ? escapeGroup(pattern)\n : '[^' + escapeString(delimiter === defaultDelimiter ? delimiter : (delimiter + defaultDelimiter)) + ']+?'\n })\n }\n\n // Push any remaining characters.\n if (path || index < str.length) {\n tokens.push(path + str.substr(index))\n }\n\n return tokens\n}\n\n/**\n * Compile a string to a template function for the path.\n *\n * @param {string} str\n * @param {Object=} options\n * @return {!function(Object=, Object=)}\n */\nfunction compile (str, options) {\n return tokensToFunction(parse(str, options), options)\n}\n\n/**\n * Expose a method for transforming tokens into the path function.\n */\nfunction tokensToFunction (tokens, options) {\n // Compile all the tokens into regexps.\n var matches = new Array(tokens.length)\n\n // Compile all the patterns before compilation.\n for (var i = 0; i < tokens.length; i++) {\n if (typeof tokens[i] === 'object') {\n matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$', flags(options))\n }\n }\n\n return function (data, options) {\n var path = ''\n var encode = (options && options.encode) || encodeURIComponent\n var validate = options ? options.validate !== false : true\n\n for (var i = 0; i < tokens.length; i++) {\n var token = tokens[i]\n\n if (typeof token === 'string') {\n path += token\n continue\n }\n\n var value = data ? data[token.name] : undefined\n var segment\n\n if (Array.isArray(value)) {\n if (!token.repeat) {\n throw new TypeError('Expected \"' + token.name + '\" to not repeat, but got array')\n }\n\n if (value.length === 0) {\n if (token.optional) continue\n\n throw new TypeError('Expected \"' + token.name + '\" to not be empty')\n }\n\n for (var j = 0; j < value.length; j++) {\n segment = encode(value[j], token)\n\n if (validate && !matches[i].test(segment)) {\n throw new TypeError('Expected all \"' + token.name + '\" to match \"' + token.pattern + '\"')\n }\n\n path += (j === 0 ? token.prefix : token.delimiter) + segment\n }\n\n continue\n }\n\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\n segment = encode(String(value), token)\n\n if (validate && !matches[i].test(segment)) {\n throw new TypeError('Expected \"' + token.name + '\" to match \"' + token.pattern + '\", but got \"' + segment + '\"')\n }\n\n path += token.prefix + segment\n continue\n }\n\n if (token.optional) continue\n\n throw new TypeError('Expected \"' + token.name + '\" to be ' + (token.repeat ? 'an array' : 'a string'))\n }\n\n return path\n }\n}\n\n/**\n * Escape a regular expression string.\n *\n * @param {string} str\n * @return {string}\n */\nfunction escapeString (str) {\n return str.replace(/([.+*?=^!:${}()[\\]|/\\\\])/g, '\\\\$1')\n}\n\n/**\n * Escape the capturing group by escaping special characters and meaning.\n *\n * @param {string} group\n * @return {string}\n */\nfunction escapeGroup (group) {\n return group.replace(/([=!:$/()])/g, '\\\\$1')\n}\n\n/**\n * Get the flags for a regexp from the options.\n *\n * @param {Object} options\n * @return {string}\n */\nfunction flags (options) {\n return options && options.sensitive ? '' : 'i'\n}\n\n/**\n * Pull out keys from a regexp.\n *\n * @param {!RegExp} path\n * @param {Array=} keys\n * @return {!RegExp}\n */\nfunction regexpToRegexp (path, keys) {\n if (!keys) return path\n\n // Use a negative lookahead to match only capturing groups.\n var groups = path.source.match(/\\((?!\\?)/g)\n\n if (groups) {\n for (var i = 0; i < groups.length; i++) {\n keys.push({\n name: i,\n prefix: null,\n delimiter: null,\n optional: false,\n repeat: false,\n pattern: null\n })\n }\n }\n\n return path\n}\n\n/**\n * Transform an array into a regexp.\n *\n * @param {!Array} path\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction arrayToRegexp (path, keys, options) {\n var parts = []\n\n for (var i = 0; i < path.length; i++) {\n parts.push(pathToRegexp(path[i], keys, options).source)\n }\n\n return new RegExp('(?:' + parts.join('|') + ')', flags(options))\n}\n\n/**\n * Create a path regexp from string input.\n *\n * @param {string} path\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction stringToRegexp (path, keys, options) {\n return tokensToRegExp(parse(path, options), keys, options)\n}\n\n/**\n * Expose a function for taking tokens and returning a RegExp.\n *\n * @param {!Array} tokens\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction tokensToRegExp (tokens, keys, options) {\n options = options || {}\n\n var strict = options.strict\n var start = options.start !== false\n var end = options.end !== false\n var delimiter = options.delimiter || DEFAULT_DELIMITER\n var endsWith = [].concat(options.endsWith || []).map(escapeString).concat('$').join('|')\n var route = start ? '^' : ''\n\n // Iterate over the tokens and create our regexp string.\n for (var i = 0; i < tokens.length; i++) {\n var token = tokens[i]\n\n if (typeof token === 'string') {\n route += escapeString(token)\n } else {\n var capture = token.repeat\n ? '(?:' + token.pattern + ')(?:' + escapeString(token.delimiter) + '(?:' + token.pattern + '))*'\n : token.pattern\n\n if (keys) keys.push(token)\n\n if (token.optional) {\n if (!token.prefix) {\n route += '(' + capture + ')?'\n } else {\n route += '(?:' + escapeString(token.prefix) + '(' + capture + '))?'\n }\n } else {\n route += escapeString(token.prefix) + '(' + capture + ')'\n }\n }\n }\n\n if (end) {\n if (!strict) route += '(?:' + escapeString(delimiter) + ')?'\n\n route += endsWith === '$' ? '$' : '(?=' + endsWith + ')'\n } else {\n var endToken = tokens[tokens.length - 1]\n var isEndDelimited = typeof endToken === 'string'\n ? endToken[endToken.length - 1] === delimiter\n : endToken === undefined\n\n if (!strict) route += '(?:' + escapeString(delimiter) + '(?=' + endsWith + '))?'\n if (!isEndDelimited) route += '(?=' + escapeString(delimiter) + '|' + endsWith + ')'\n }\n\n return new RegExp(route, flags(options))\n}\n\n/**\n * Normalize the given path string, returning a regular expression.\n *\n * An empty array can be passed in for the keys, which will hold the\n * placeholder key descriptions. For example, using `/user/:id`, `keys` will\n * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.\n *\n * @param {(string|RegExp|Array)} path\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction pathToRegexp (path, keys, options) {\n if (path instanceof RegExp) {\n return regexpToRegexp(path, keys)\n }\n\n if (Array.isArray(path)) {\n return arrayToRegexp(/** @type {!Array} */ (path), keys, options)\n }\n\n return stringToRegexp(/** @type {string} */ (path), keys, options)\n}\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nimport pathToRegexp from 'path-to-regexp'\n\nconst { hasOwnProperty } = Object.prototype\nconst cache = new Map()\n\nfunction decodeParam(val) {\n try {\n return decodeURIComponent(val)\n } catch (err) {\n return val\n }\n}\n\nfunction matchPath(route, pathname, parentKeys, parentParams) {\n const end = !route.children\n const cacheKey = `${route.path || ''}|${end}`\n let regexp = cache.get(cacheKey)\n\n if (!regexp) {\n const keys = []\n regexp = {\n keys,\n pattern: pathToRegexp(route.path || '', keys, { end }),\n }\n cache.set(cacheKey, regexp)\n }\n\n const m = regexp.pattern.exec(pathname)\n if (!m) {\n return null\n }\n\n const path = m[0]\n const params = { ...parentParams }\n\n for (let i = 1; i < m.length; i++) {\n const key = regexp.keys[i - 1]\n const prop = key.name\n const value = m[i]\n if (value !== undefined || !hasOwnProperty.call(params, prop)) {\n if (key.repeat) {\n params[prop] = value ? value.split(key.delimiter).map(decodeParam) : []\n } else {\n params[prop] = value ? decodeParam(value) : value\n }\n }\n }\n\n return {\n path: !end && path.charAt(path.length - 1) === '/' ? path.substr(1) : path,\n keys: parentKeys.concat(regexp.keys),\n params,\n }\n}\n\nexport default matchPath\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nimport matchPath from './matchPath'\n\nfunction matchRoute(route, baseUrl, pathname, parentKeys, parentParams) {\n let match\n let childMatches\n let childIndex = 0\n\n return {\n next(routeToSkip) {\n if (route === routeToSkip) {\n return { done: true }\n }\n\n if (!match) {\n match = matchPath(route, pathname, parentKeys, parentParams)\n\n if (match) {\n return {\n done: false,\n value: {\n route,\n baseUrl,\n path: match.path,\n keys: match.keys,\n params: match.params,\n },\n }\n }\n }\n\n if (match && route.children) {\n while (childIndex < route.children.length) {\n if (!childMatches) {\n const childRoute = route.children[childIndex]\n childRoute.parent = route\n\n childMatches = matchRoute(\n childRoute,\n baseUrl + match.path,\n pathname.substr(match.path.length),\n match.keys,\n match.params,\n )\n }\n\n const childMatch = childMatches.next(routeToSkip)\n if (!childMatch.done) {\n return {\n done: false,\n value: childMatch.value,\n }\n }\n\n childMatches = null\n childIndex++\n }\n }\n\n return { done: true }\n },\n }\n}\n\nexport default matchRoute\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nfunction resolveRoute(context, params) {\n if (typeof context.route.action === 'function') {\n return context.route.action(context, params)\n }\n return undefined\n}\n\nexport default resolveRoute\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nfunction isChildRoute(parentRoute, childRoute) {\n let route = childRoute\n while (route) {\n route = route.parent\n if (route === parentRoute) {\n return true\n }\n }\n return false\n}\n\nexport default isChildRoute\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nimport pathToRegexp from 'path-to-regexp'\nimport matchRoute from './matchRoute'\nimport resolveRoute from './resolveRoute'\nimport isChildRoute from './isChildRoute'\n\nclass UniversalRouter {\n constructor(routes, options = {}) {\n if (!routes || typeof routes !== 'object') {\n throw new TypeError('Invalid routes')\n }\n\n this.baseUrl = options.baseUrl || ''\n this.errorHandler = options.errorHandler\n this.resolveRoute = options.resolveRoute || resolveRoute\n this.context = { router: this, ...options.context }\n this.root = Array.isArray(routes) ? { path: '', children: routes, parent: null } : routes\n this.root.parent = null\n }\n\n resolve(pathnameOrContext) {\n const context = {\n ...this.context,\n ...(typeof pathnameOrContext === 'string'\n ? { pathname: pathnameOrContext }\n : pathnameOrContext),\n }\n const match = matchRoute(\n this.root,\n this.baseUrl,\n context.pathname.substr(this.baseUrl.length),\n [],\n null,\n )\n const resolve = this.resolveRoute\n let matches = null\n let nextMatches = null\n let currentContext = context\n\n function next(resume, parent = matches.value.route, prevResult) {\n const routeToSkip = prevResult === null && !matches.done && matches.value.route\n matches = nextMatches || match.next(routeToSkip)\n nextMatches = null\n\n if (!resume) {\n if (matches.done || !isChildRoute(parent, matches.value.route)) {\n nextMatches = matches\n return Promise.resolve(null)\n }\n }\n\n if (matches.done) {\n const error = new Error('Route not found')\n error.status = 404\n return Promise.reject(error)\n }\n\n currentContext = { ...context, ...matches.value }\n\n return Promise.resolve(resolve(currentContext, matches.value.params)).then((result) => {\n if (result !== null && result !== undefined) {\n return result\n }\n return next(resume, parent, result)\n })\n }\n\n context.next = next\n\n return Promise.resolve()\n .then(() => next(true, this.root))\n .catch((error) => {\n if (this.errorHandler) {\n return this.errorHandler(error, currentContext)\n }\n throw error\n })\n }\n}\n\nUniversalRouter.pathToRegexp = pathToRegexp\n\nexport default UniversalRouter\n"],"names":["pathToRegexp","parse","compile","tokensToFunction","tokensToRegExp","DEFAULT_DELIMITER","PATH_REGEXP","RegExp","join","str","options","tokens","key","index","path","defaultDelimiter","delimiter","whitelist","undefined","pathEscaped","res","exec","m","escaped","offset","slice","length","prev","name","capture","group","modifier","k","c","matches","indexOf","push","repeat","optional","pattern","prefix","escapeGroup","escapeString","substr","Array","i","flags","data","encode","encodeURIComponent","validate","token","value","segment","isArray","TypeError","j","test","String","replace","sensitive","regexpToRegexp","keys","groups","source","match","arrayToRegexp","parts","stringToRegexp","strict","start","end","endsWith","concat","map","route","endToken","isEndDelimited","hasOwnProperty","Object","prototype","cache","Map","decodeParam","val","decodeURIComponent","err","matchPath","pathname","parentKeys","parentParams","children","cacheKey","regexp","get","set","params","prop","call","split","charAt","matchRoute","baseUrl","childMatches","childIndex","next","routeToSkip","done","childRoute","parent","childMatch","resolveRoute","context","action","isChildRoute","parentRoute","UniversalRouter","routes","errorHandler","router","root","resolve","pathnameOrContext","nextMatches","currentContext","resume","prevResult","Promise","error","Error","status","reject","then","result"],"mappings":";;;;;;;;EAGA,kBAAc,GAAGA,YAAjB;EACA,WAAoB,GAAGC,KAAvB;EACA,aAAsB,GAAGC,OAAzB;EACA,sBAA+B,GAAGC,gBAAlC;EACA,oBAA6B,GAAGC,cAAhC;EAKA,IAAIC,iBAAiB,GAAG,GAAxB;EAOA,IAAIC,WAAW,GAAG,IAAIC,MAAJ,CAAW,CAG3B,SAH2B,EAS3B,qFAT2B,EAU3BC,IAV2B,CAUtB,GAVsB,CAAX,EAUL,GAVK,CAAlB;;EAmBA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A+BA,cAA/B;;;;;;;;"} \ No newline at end of file diff --git a/dist/universal-router.min.js b/dist/universal-router.min.js index af1c047..02c14eb 100644 --- a/dist/universal-router.min.js +++ b/dist/universal-router.min.js @@ -1,3 +1,3 @@ /*! 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=e||self).UniversalRouter=t()}(this,function(){"use strict";function e(e,t){return i(o(e,t))}var d=u,t=o,r=i,n=a,k="/",T=new RegExp(["(\\\\.)","(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?"].join("|"),"g");function o(e,t){for(var r,n,o=[],i=0,a=0,u="",l=t&&t.delimiter||k,s=t&&t.whitelist||void 0,p=!1;null!==(r=T.exec(e));){var f=r[0],c=r[1],h=r.index;if(u+=e.slice(a,h),a=h+f.length,c)u+=c[1],p=!0;else{var v="",d=r[2],g=r[3],m=r[4],y=r[5];if(!p&&u.length){var x=u.length-1,b=u[x];(!s||-1 [\"test\", \"\\d+\", undefined, \"?\"]\n // \"(\\\\d+)\" => [undefined, undefined, \"\\d+\", undefined]\n '(?:\\\\:(\\\\w+)(?:\\\\(((?:\\\\\\\\.|[^\\\\\\\\()])+)\\\\))?|\\\\(((?:\\\\\\\\.|[^\\\\\\\\()])+)\\\\))([+*?])?'\n].join('|'), 'g')\n\n/**\n * Parse a string for the raw tokens.\n *\n * @param {string} str\n * @param {Object=} options\n * @return {!Array}\n */\nfunction parse (str, options) {\n var tokens = []\n var key = 0\n var index = 0\n var path = ''\n var defaultDelimiter = (options && options.delimiter) || DEFAULT_DELIMITER\n var whitelist = (options && options.whitelist) || undefined\n var pathEscaped = false\n var res\n\n while ((res = PATH_REGEXP.exec(str)) !== null) {\n var m = res[0]\n var escaped = res[1]\n var offset = res.index\n path += str.slice(index, offset)\n index = offset + m.length\n\n // Ignore already escaped sequences.\n if (escaped) {\n path += escaped[1]\n pathEscaped = true\n continue\n }\n\n var prev = ''\n var name = res[2]\n var capture = res[3]\n var group = res[4]\n var modifier = res[5]\n\n if (!pathEscaped && path.length) {\n var k = path.length - 1\n var c = path[k]\n var matches = whitelist ? whitelist.indexOf(c) > -1 : true\n\n if (matches) {\n prev = c\n path = path.slice(0, k)\n }\n }\n\n // Push the current path onto the tokens.\n if (path) {\n tokens.push(path)\n path = ''\n pathEscaped = false\n }\n\n var repeat = modifier === '+' || modifier === '*'\n var optional = modifier === '?' || modifier === '*'\n var pattern = capture || group\n var delimiter = prev || defaultDelimiter\n\n tokens.push({\n name: name || key++,\n prefix: prev,\n delimiter: delimiter,\n optional: optional,\n repeat: repeat,\n pattern: pattern\n ? escapeGroup(pattern)\n : '[^' + escapeString(delimiter === defaultDelimiter ? delimiter : (delimiter + defaultDelimiter)) + ']+?'\n })\n }\n\n // Push any remaining characters.\n if (path || index < str.length) {\n tokens.push(path + str.substr(index))\n }\n\n return tokens\n}\n\n/**\n * Compile a string to a template function for the path.\n *\n * @param {string} str\n * @param {Object=} options\n * @return {!function(Object=, Object=)}\n */\nfunction compile (str, options) {\n return tokensToFunction(parse(str, options))\n}\n\n/**\n * Expose a method for transforming tokens into the path function.\n */\nfunction tokensToFunction (tokens) {\n // Compile all the tokens into regexps.\n var matches = new Array(tokens.length)\n\n // Compile all the patterns before compilation.\n for (var i = 0; i < tokens.length; i++) {\n if (typeof tokens[i] === 'object') {\n matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$')\n }\n }\n\n return function (data, options) {\n var path = ''\n var encode = (options && options.encode) || encodeURIComponent\n\n for (var i = 0; i < tokens.length; i++) {\n var token = tokens[i]\n\n if (typeof token === 'string') {\n path += token\n continue\n }\n\n var value = data ? data[token.name] : undefined\n var segment\n\n if (Array.isArray(value)) {\n if (!token.repeat) {\n throw new TypeError('Expected \"' + token.name + '\" to not repeat, but got array')\n }\n\n if (value.length === 0) {\n if (token.optional) continue\n\n throw new TypeError('Expected \"' + token.name + '\" to not be empty')\n }\n\n for (var j = 0; j < value.length; j++) {\n segment = encode(value[j], token)\n\n if (!matches[i].test(segment)) {\n throw new TypeError('Expected all \"' + token.name + '\" to match \"' + token.pattern + '\"')\n }\n\n path += (j === 0 ? token.prefix : token.delimiter) + segment\n }\n\n continue\n }\n\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\n segment = encode(String(value), token)\n\n if (!matches[i].test(segment)) {\n throw new TypeError('Expected \"' + token.name + '\" to match \"' + token.pattern + '\", but got \"' + segment + '\"')\n }\n\n path += token.prefix + segment\n continue\n }\n\n if (token.optional) continue\n\n throw new TypeError('Expected \"' + token.name + '\" to be ' + (token.repeat ? 'an array' : 'a string'))\n }\n\n return path\n }\n}\n\n/**\n * Escape a regular expression string.\n *\n * @param {string} str\n * @return {string}\n */\nfunction escapeString (str) {\n return str.replace(/([.+*?=^!:${}()[\\]|/\\\\])/g, '\\\\$1')\n}\n\n/**\n * Escape the capturing group by escaping special characters and meaning.\n *\n * @param {string} group\n * @return {string}\n */\nfunction escapeGroup (group) {\n return group.replace(/([=!:$/()])/g, '\\\\$1')\n}\n\n/**\n * Get the flags for a regexp from the options.\n *\n * @param {Object} options\n * @return {string}\n */\nfunction flags (options) {\n return options && options.sensitive ? '' : 'i'\n}\n\n/**\n * Pull out keys from a regexp.\n *\n * @param {!RegExp} path\n * @param {Array=} keys\n * @return {!RegExp}\n */\nfunction regexpToRegexp (path, keys) {\n if (!keys) return path\n\n // Use a negative lookahead to match only capturing groups.\n var groups = path.source.match(/\\((?!\\?)/g)\n\n if (groups) {\n for (var i = 0; i < groups.length; i++) {\n keys.push({\n name: i,\n prefix: null,\n delimiter: null,\n optional: false,\n repeat: false,\n pattern: null\n })\n }\n }\n\n return path\n}\n\n/**\n * Transform an array into a regexp.\n *\n * @param {!Array} path\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction arrayToRegexp (path, keys, options) {\n var parts = []\n\n for (var i = 0; i < path.length; i++) {\n parts.push(pathToRegexp(path[i], keys, options).source)\n }\n\n return new RegExp('(?:' + parts.join('|') + ')', flags(options))\n}\n\n/**\n * Create a path regexp from string input.\n *\n * @param {string} path\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction stringToRegexp (path, keys, options) {\n return tokensToRegExp(parse(path, options), keys, options)\n}\n\n/**\n * Expose a function for taking tokens and returning a RegExp.\n *\n * @param {!Array} tokens\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction tokensToRegExp (tokens, keys, options) {\n options = options || {}\n\n var strict = options.strict\n var start = options.start !== false\n var end = options.end !== false\n var delimiter = options.delimiter || DEFAULT_DELIMITER\n var endsWith = [].concat(options.endsWith || []).map(escapeString).concat('$').join('|')\n var route = start ? '^' : ''\n\n // Iterate over the tokens and create our regexp string.\n for (var i = 0; i < tokens.length; i++) {\n var token = tokens[i]\n\n if (typeof token === 'string') {\n route += escapeString(token)\n } else {\n var capture = token.repeat\n ? '(?:' + token.pattern + ')(?:' + escapeString(token.delimiter) + '(?:' + token.pattern + '))*'\n : token.pattern\n\n if (keys) keys.push(token)\n\n if (token.optional) {\n if (!token.prefix) {\n route += '(' + capture + ')?'\n } else {\n route += '(?:' + escapeString(token.prefix) + '(' + capture + '))?'\n }\n } else {\n route += escapeString(token.prefix) + '(' + capture + ')'\n }\n }\n }\n\n if (end) {\n if (!strict) route += '(?:' + escapeString(delimiter) + ')?'\n\n route += endsWith === '$' ? '$' : '(?=' + endsWith + ')'\n } else {\n var endToken = tokens[tokens.length - 1]\n var isEndDelimited = typeof endToken === 'string'\n ? endToken[endToken.length - 1] === delimiter\n : endToken === undefined\n\n if (!strict) route += '(?:' + escapeString(delimiter) + '(?=' + endsWith + '))?'\n if (!isEndDelimited) route += '(?=' + escapeString(delimiter) + '|' + endsWith + ')'\n }\n\n return new RegExp(route, flags(options))\n}\n\n/**\n * Normalize the given path string, returning a regular expression.\n *\n * An empty array can be passed in for the keys, which will hold the\n * placeholder key descriptions. For example, using `/user/:id`, `keys` will\n * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.\n *\n * @param {(string|RegExp|Array)} path\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction pathToRegexp (path, keys, options) {\n if (path instanceof RegExp) {\n return regexpToRegexp(path, keys)\n }\n\n if (Array.isArray(path)) {\n return arrayToRegexp(/** @type {!Array} */ (path), keys, options)\n }\n\n return stringToRegexp(/** @type {string} */ (path), keys, options)\n}\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nimport pathToRegexp from 'path-to-regexp'\n\nconst { hasOwnProperty } = Object.prototype\nconst cache = new Map()\n\nfunction decodeParam(val) {\n try {\n return decodeURIComponent(val)\n } catch (err) {\n return val\n }\n}\n\nfunction matchPath(route, pathname, parentKeys, parentParams) {\n const end = !route.children\n const cacheKey = `${route.path || ''}|${end}`\n let regexp = cache.get(cacheKey)\n\n if (!regexp) {\n const keys = []\n regexp = {\n keys,\n pattern: pathToRegexp(route.path || '', keys, { end }),\n }\n cache.set(cacheKey, regexp)\n }\n\n const m = regexp.pattern.exec(pathname)\n if (!m) {\n return null\n }\n\n const path = m[0]\n const params = { ...parentParams }\n\n for (let i = 1; i < m.length; i++) {\n const key = regexp.keys[i - 1]\n const prop = key.name\n const value = m[i]\n if (value !== undefined || !hasOwnProperty.call(params, prop)) {\n if (key.repeat) {\n params[prop] = value ? value.split(key.delimiter).map(decodeParam) : []\n } else {\n params[prop] = value ? decodeParam(value) : value\n }\n }\n }\n\n return {\n path: !end && path.charAt(path.length - 1) === '/' ? path.substr(1) : path,\n keys: parentKeys.concat(regexp.keys),\n params,\n }\n}\n\nexport default matchPath\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nimport matchPath from './matchPath'\n\nfunction matchRoute(route, baseUrl, pathname, parentKeys, parentParams) {\n let match\n let childMatches\n let childIndex = 0\n\n return {\n next(routeToSkip) {\n if (route === routeToSkip) {\n return { done: true }\n }\n\n if (!match) {\n match = matchPath(route, pathname, parentKeys, parentParams)\n\n if (match) {\n return {\n done: false,\n value: {\n route,\n baseUrl,\n path: match.path,\n keys: match.keys,\n params: match.params,\n },\n }\n }\n }\n\n if (match && route.children) {\n while (childIndex < route.children.length) {\n if (!childMatches) {\n const childRoute = route.children[childIndex]\n childRoute.parent = route\n\n childMatches = matchRoute(\n childRoute,\n baseUrl + match.path,\n pathname.substr(match.path.length),\n match.keys,\n match.params,\n )\n }\n\n const childMatch = childMatches.next(routeToSkip)\n if (!childMatch.done) {\n return {\n done: false,\n value: childMatch.value,\n }\n }\n\n childMatches = null\n childIndex++\n }\n }\n\n return { done: true }\n },\n }\n}\n\nexport default matchRoute\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nfunction resolveRoute(context, params) {\n if (typeof context.route.action === 'function') {\n return context.route.action(context, params)\n }\n return undefined\n}\n\nexport default resolveRoute\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nimport pathToRegexp from 'path-to-regexp'\nimport matchRoute from './matchRoute'\nimport resolveRoute from './resolveRoute'\nimport isChildRoute from './isChildRoute'\n\nclass UniversalRouter {\n constructor(routes, options = {}) {\n if (!routes || typeof routes !== 'object') {\n throw new TypeError('Invalid routes')\n }\n\n this.baseUrl = options.baseUrl || ''\n this.errorHandler = options.errorHandler\n this.resolveRoute = options.resolveRoute || resolveRoute\n this.context = { router: this, ...options.context }\n this.root = Array.isArray(routes) ? { path: '', children: routes, parent: null } : routes\n this.root.parent = null\n }\n\n resolve(pathnameOrContext) {\n const context = {\n ...this.context,\n ...(typeof pathnameOrContext === 'string'\n ? { pathname: pathnameOrContext }\n : pathnameOrContext),\n }\n const match = matchRoute(\n this.root,\n this.baseUrl,\n context.pathname.substr(this.baseUrl.length),\n [],\n null,\n )\n const resolve = this.resolveRoute\n let matches = null\n let nextMatches = null\n let currentContext = context\n\n function next(resume, parent = matches.value.route, prevResult) {\n const routeToSkip = prevResult === null && !matches.done && matches.value.route\n matches = nextMatches || match.next(routeToSkip)\n nextMatches = null\n\n if (!resume) {\n if (matches.done || !isChildRoute(parent, matches.value.route)) {\n nextMatches = matches\n return Promise.resolve(null)\n }\n }\n\n if (matches.done) {\n const error = new Error('Route not found')\n error.status = 404\n return Promise.reject(error)\n }\n\n currentContext = { ...context, ...matches.value }\n\n return Promise.resolve(resolve(currentContext, matches.value.params)).then((result) => {\n if (result !== null && result !== undefined) {\n return result\n }\n return next(resume, parent, result)\n })\n }\n\n context.next = next\n\n return Promise.resolve()\n .then(() => next(true, this.root))\n .catch((error) => {\n if (this.errorHandler) {\n return this.errorHandler(error, currentContext)\n }\n throw error\n })\n }\n}\n\nUniversalRouter.pathToRegexp = pathToRegexp\n\nexport default UniversalRouter\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nfunction isChildRoute(parentRoute, childRoute) {\n let route = childRoute\n while (route) {\n route = route.parent\n if (route === parentRoute) {\n return true\n }\n }\n return false\n}\n\nexport default isChildRoute\n"],"names":["str","options","tokensToFunction","parse","pathToRegexp","tokensToRegExp","DEFAULT_DELIMITER","PATH_REGEXP","RegExp","join","res","group","tokens","key","index","path","defaultDelimiter","delimiter","whitelist","undefined","pathEscaped","exec","m","escaped","offset","slice","length","prev","name","capture","modifier","k","c","indexOf","push","repeat","optional","pattern","prefix","replace","escapeString","substr","matches","Array","i","data","encode","encodeURIComponent","token","segment","value","isArray","TypeError","j","test","String","flags","sensitive","keys","strict","start","end","endsWith","concat","map","route","endToken","isEndDelimited","groups","source","match","regexpToRegexp","parts","arrayToRegexp","stringToRegexp","hasOwnProperty","Object","prototype","cache","Map","decodeParam","val","decodeURIComponent","err","matchRoute","baseUrl","pathname","parentKeys","parentParams","childMatches","childIndex","next","routeToSkip","done","children","cacheKey","regexp","get","set","params","prop","call","split","charAt","matchPath","childRoute","parent","childMatch","resolveRoute","context","action","UniversalRouter","resolve","pathnameOrContext","this","root","nextMatches","currentContext","resume","prevResult","parentRoute","isChildRoute","Promise","error","Error","status","reject","then","result","_this","errorHandler","routes","router"],"mappings":";qMAsHA,WAAkBA,EAAKC,UACdC,EAAiBC,EAAMH,EAAKC,IApHrC,MAAiBG,IACMD,IAEWD,IACFG,EAK5BC,EAAoB,IAOpBC,EAAc,IAAIC,OAAO,CAG3B,UAMA,uFACAC,KAAK,KAAM,KASb,SAASN,EAAOH,EAAKC,WAQfS,EAqKgBC,EA5KhBC,EAAS,GACTC,EAAM,EACNC,EAAQ,EACRC,EAAO,GACPC,EAAoBf,GAAWA,EAAQgB,WAAcX,EACrDY,EAAajB,GAAWA,EAAQiB,gBAAcC,EAC9CC,GAAc,EAGuB,QAAjCV,EAAMH,EAAYc,KAAKrB,KAAgB,KACzCsB,EAAIZ,EAAI,GACRa,EAAUb,EAAI,GACdc,EAASd,EAAII,SACjBC,GAAQf,EAAIyB,MAAMX,EAAOU,GACzBV,EAAQU,EAASF,EAAEI,OAGfH,EACFR,GAAQQ,EAAQ,GAChBH,GAAc,WAIZO,EAAO,GACPC,EAAOlB,EAAI,GACXmB,EAAUnB,EAAI,GACdC,EAAQD,EAAI,GACZoB,EAAWpB,EAAI,OAEdU,GAAeL,EAAKW,OAAQ,KAC3BK,EAAIhB,EAAKW,OAAS,EAClBM,EAAI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AAQmD,KAAM,KACV8B,EAAQ,IAAIC,MAAM,0BACxBD,EAAME,OAAS,IACRH,QAAQI,OAAOH,UAGxBN,mBAAsBR,KAAYnE,EAAQQ,OAEnCwE,QAAQV,QAAQA,EAAQK,EAAgB3E,EAAQQ,MAAMiD,SAAS4B,KAAK,SAACC,UACtEA,MAAAA,EACKA,EAEFrC,EAAK2B,EAAQZ,EAAQsB,YAIhCnB,EAAQlB,KAAOA,EAER+B,QAAQV,UACZe,KAAK,kBAAMpC,GAAK,EAAMsC,EAAKd,cACrB,SAACQ,MACFM,EAAKC,oBACAD,EAAKC,aAAaP,EAAON,SAE5BM,mBApEAQ,EAAQlI,eAAAA,IAAAA,EAAU,KACvBkI,GAA4B,iBAAXA,QACd,IAAI/E,UAAU,uBAGjBiC,QAAUpF,EAAQoF,SAAW,QAC7B6C,aAAejI,EAAQiI,kBACvBtB,aAAe3G,EAAQ2G,cAAgBA,OACvCC,uBAAYuB,OAAQlB,MAASjH,EAAQ4G,cACrCM,KAAOxE,MAAMQ,QAAQgF,GAAU,CAAEpH,KAAM,GAAI+E,SAAUqC,EAAQzB,OAAQ,MAASyB,OAC9EhB,KAAKT,OAAS,YA+DvBK,EAAgB3G,aAAeA"} \ No newline at end of file +{"version":3,"file":"universal-router.min.js","sources":["../node_modules/path-to-regexp/index.js","src/matchPath.js","src/matchRoute.js","src/resolveRoute.js","src/UniversalRouter.js","src/isChildRoute.js"],"sourcesContent":["/**\n * Expose `pathToRegexp`.\n */\nmodule.exports = pathToRegexp\nmodule.exports.parse = parse\nmodule.exports.compile = compile\nmodule.exports.tokensToFunction = tokensToFunction\nmodule.exports.tokensToRegExp = tokensToRegExp\n\n/**\n * Default configs.\n */\nvar DEFAULT_DELIMITER = '/'\n\n/**\n * The main path matching regexp utility.\n *\n * @type {RegExp}\n */\nvar PATH_REGEXP = new RegExp([\n // Match escaped characters that would otherwise appear in future matches.\n // This allows the user to escape special characters that won't transform.\n '(\\\\\\\\.)',\n // Match Express-style parameters and un-named parameters with a prefix\n // and optional suffixes. Matches appear as:\n //\n // \":test(\\\\d+)?\" => [\"test\", \"\\d+\", undefined, \"?\"]\n // \"(\\\\d+)\" => [undefined, undefined, \"\\d+\", undefined]\n '(?:\\\\:(\\\\w+)(?:\\\\(((?:\\\\\\\\.|[^\\\\\\\\()])+)\\\\))?|\\\\(((?:\\\\\\\\.|[^\\\\\\\\()])+)\\\\))([+*?])?'\n].join('|'), 'g')\n\n/**\n * Parse a string for the raw tokens.\n *\n * @param {string} str\n * @param {Object=} options\n * @return {!Array}\n */\nfunction parse (str, options) {\n var tokens = []\n var key = 0\n var index = 0\n var path = ''\n var defaultDelimiter = (options && options.delimiter) || DEFAULT_DELIMITER\n var whitelist = (options && options.whitelist) || undefined\n var pathEscaped = false\n var res\n\n while ((res = PATH_REGEXP.exec(str)) !== null) {\n var m = res[0]\n var escaped = res[1]\n var offset = res.index\n path += str.slice(index, offset)\n index = offset + m.length\n\n // Ignore already escaped sequences.\n if (escaped) {\n path += escaped[1]\n pathEscaped = true\n continue\n }\n\n var prev = ''\n var name = res[2]\n var capture = res[3]\n var group = res[4]\n var modifier = res[5]\n\n if (!pathEscaped && path.length) {\n var k = path.length - 1\n var c = path[k]\n var matches = whitelist ? whitelist.indexOf(c) > -1 : true\n\n if (matches) {\n prev = c\n path = path.slice(0, k)\n }\n }\n\n // Push the current path onto the tokens.\n if (path) {\n tokens.push(path)\n path = ''\n pathEscaped = false\n }\n\n var repeat = modifier === '+' || modifier === '*'\n var optional = modifier === '?' || modifier === '*'\n var pattern = capture || group\n var delimiter = prev || defaultDelimiter\n\n tokens.push({\n name: name || key++,\n prefix: prev,\n delimiter: delimiter,\n optional: optional,\n repeat: repeat,\n pattern: pattern\n ? escapeGroup(pattern)\n : '[^' + escapeString(delimiter === defaultDelimiter ? delimiter : (delimiter + defaultDelimiter)) + ']+?'\n })\n }\n\n // Push any remaining characters.\n if (path || index < str.length) {\n tokens.push(path + str.substr(index))\n }\n\n return tokens\n}\n\n/**\n * Compile a string to a template function for the path.\n *\n * @param {string} str\n * @param {Object=} options\n * @return {!function(Object=, Object=)}\n */\nfunction compile (str, options) {\n return tokensToFunction(parse(str, options), options)\n}\n\n/**\n * Expose a method for transforming tokens into the path function.\n */\nfunction tokensToFunction (tokens, options) {\n // Compile all the tokens into regexps.\n var matches = new Array(tokens.length)\n\n // Compile all the patterns before compilation.\n for (var i = 0; i < tokens.length; i++) {\n if (typeof tokens[i] === 'object') {\n matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$', flags(options))\n }\n }\n\n return function (data, options) {\n var path = ''\n var encode = (options && options.encode) || encodeURIComponent\n var validate = options ? options.validate !== false : true\n\n for (var i = 0; i < tokens.length; i++) {\n var token = tokens[i]\n\n if (typeof token === 'string') {\n path += token\n continue\n }\n\n var value = data ? data[token.name] : undefined\n var segment\n\n if (Array.isArray(value)) {\n if (!token.repeat) {\n throw new TypeError('Expected \"' + token.name + '\" to not repeat, but got array')\n }\n\n if (value.length === 0) {\n if (token.optional) continue\n\n throw new TypeError('Expected \"' + token.name + '\" to not be empty')\n }\n\n for (var j = 0; j < value.length; j++) {\n segment = encode(value[j], token)\n\n if (validate && !matches[i].test(segment)) {\n throw new TypeError('Expected all \"' + token.name + '\" to match \"' + token.pattern + '\"')\n }\n\n path += (j === 0 ? token.prefix : token.delimiter) + segment\n }\n\n continue\n }\n\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\n segment = encode(String(value), token)\n\n if (validate && !matches[i].test(segment)) {\n throw new TypeError('Expected \"' + token.name + '\" to match \"' + token.pattern + '\", but got \"' + segment + '\"')\n }\n\n path += token.prefix + segment\n continue\n }\n\n if (token.optional) continue\n\n throw new TypeError('Expected \"' + token.name + '\" to be ' + (token.repeat ? 'an array' : 'a string'))\n }\n\n return path\n }\n}\n\n/**\n * Escape a regular expression string.\n *\n * @param {string} str\n * @return {string}\n */\nfunction escapeString (str) {\n return str.replace(/([.+*?=^!:${}()[\\]|/\\\\])/g, '\\\\$1')\n}\n\n/**\n * Escape the capturing group by escaping special characters and meaning.\n *\n * @param {string} group\n * @return {string}\n */\nfunction escapeGroup (group) {\n return group.replace(/([=!:$/()])/g, '\\\\$1')\n}\n\n/**\n * Get the flags for a regexp from the options.\n *\n * @param {Object} options\n * @return {string}\n */\nfunction flags (options) {\n return options && options.sensitive ? '' : 'i'\n}\n\n/**\n * Pull out keys from a regexp.\n *\n * @param {!RegExp} path\n * @param {Array=} keys\n * @return {!RegExp}\n */\nfunction regexpToRegexp (path, keys) {\n if (!keys) return path\n\n // Use a negative lookahead to match only capturing groups.\n var groups = path.source.match(/\\((?!\\?)/g)\n\n if (groups) {\n for (var i = 0; i < groups.length; i++) {\n keys.push({\n name: i,\n prefix: null,\n delimiter: null,\n optional: false,\n repeat: false,\n pattern: null\n })\n }\n }\n\n return path\n}\n\n/**\n * Transform an array into a regexp.\n *\n * @param {!Array} path\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction arrayToRegexp (path, keys, options) {\n var parts = []\n\n for (var i = 0; i < path.length; i++) {\n parts.push(pathToRegexp(path[i], keys, options).source)\n }\n\n return new RegExp('(?:' + parts.join('|') + ')', flags(options))\n}\n\n/**\n * Create a path regexp from string input.\n *\n * @param {string} path\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction stringToRegexp (path, keys, options) {\n return tokensToRegExp(parse(path, options), keys, options)\n}\n\n/**\n * Expose a function for taking tokens and returning a RegExp.\n *\n * @param {!Array} tokens\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction tokensToRegExp (tokens, keys, options) {\n options = options || {}\n\n var strict = options.strict\n var start = options.start !== false\n var end = options.end !== false\n var delimiter = options.delimiter || DEFAULT_DELIMITER\n var endsWith = [].concat(options.endsWith || []).map(escapeString).concat('$').join('|')\n var route = start ? '^' : ''\n\n // Iterate over the tokens and create our regexp string.\n for (var i = 0; i < tokens.length; i++) {\n var token = tokens[i]\n\n if (typeof token === 'string') {\n route += escapeString(token)\n } else {\n var capture = token.repeat\n ? '(?:' + token.pattern + ')(?:' + escapeString(token.delimiter) + '(?:' + token.pattern + '))*'\n : token.pattern\n\n if (keys) keys.push(token)\n\n if (token.optional) {\n if (!token.prefix) {\n route += '(' + capture + ')?'\n } else {\n route += '(?:' + escapeString(token.prefix) + '(' + capture + '))?'\n }\n } else {\n route += escapeString(token.prefix) + '(' + capture + ')'\n }\n }\n }\n\n if (end) {\n if (!strict) route += '(?:' + escapeString(delimiter) + ')?'\n\n route += endsWith === '$' ? '$' : '(?=' + endsWith + ')'\n } else {\n var endToken = tokens[tokens.length - 1]\n var isEndDelimited = typeof endToken === 'string'\n ? endToken[endToken.length - 1] === delimiter\n : endToken === undefined\n\n if (!strict) route += '(?:' + escapeString(delimiter) + '(?=' + endsWith + '))?'\n if (!isEndDelimited) route += '(?=' + escapeString(delimiter) + '|' + endsWith + ')'\n }\n\n return new RegExp(route, flags(options))\n}\n\n/**\n * Normalize the given path string, returning a regular expression.\n *\n * An empty array can be passed in for the keys, which will hold the\n * placeholder key descriptions. For example, using `/user/:id`, `keys` will\n * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.\n *\n * @param {(string|RegExp|Array)} path\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction pathToRegexp (path, keys, options) {\n if (path instanceof RegExp) {\n return regexpToRegexp(path, keys)\n }\n\n if (Array.isArray(path)) {\n return arrayToRegexp(/** @type {!Array} */ (path), keys, options)\n }\n\n return stringToRegexp(/** @type {string} */ (path), keys, options)\n}\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nimport pathToRegexp from 'path-to-regexp'\n\nconst { hasOwnProperty } = Object.prototype\nconst cache = new Map()\n\nfunction decodeParam(val) {\n try {\n return decodeURIComponent(val)\n } catch (err) {\n return val\n }\n}\n\nfunction matchPath(route, pathname, parentKeys, parentParams) {\n const end = !route.children\n const cacheKey = `${route.path || ''}|${end}`\n let regexp = cache.get(cacheKey)\n\n if (!regexp) {\n const keys = []\n regexp = {\n keys,\n pattern: pathToRegexp(route.path || '', keys, { end }),\n }\n cache.set(cacheKey, regexp)\n }\n\n const m = regexp.pattern.exec(pathname)\n if (!m) {\n return null\n }\n\n const path = m[0]\n const params = { ...parentParams }\n\n for (let i = 1; i < m.length; i++) {\n const key = regexp.keys[i - 1]\n const prop = key.name\n const value = m[i]\n if (value !== undefined || !hasOwnProperty.call(params, prop)) {\n if (key.repeat) {\n params[prop] = value ? value.split(key.delimiter).map(decodeParam) : []\n } else {\n params[prop] = value ? decodeParam(value) : value\n }\n }\n }\n\n return {\n path: !end && path.charAt(path.length - 1) === '/' ? path.substr(1) : path,\n keys: parentKeys.concat(regexp.keys),\n params,\n }\n}\n\nexport default matchPath\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nimport matchPath from './matchPath'\n\nfunction matchRoute(route, baseUrl, pathname, parentKeys, parentParams) {\n let match\n let childMatches\n let childIndex = 0\n\n return {\n next(routeToSkip) {\n if (route === routeToSkip) {\n return { done: true }\n }\n\n if (!match) {\n match = matchPath(route, pathname, parentKeys, parentParams)\n\n if (match) {\n return {\n done: false,\n value: {\n route,\n baseUrl,\n path: match.path,\n keys: match.keys,\n params: match.params,\n },\n }\n }\n }\n\n if (match && route.children) {\n while (childIndex < route.children.length) {\n if (!childMatches) {\n const childRoute = route.children[childIndex]\n childRoute.parent = route\n\n childMatches = matchRoute(\n childRoute,\n baseUrl + match.path,\n pathname.substr(match.path.length),\n match.keys,\n match.params,\n )\n }\n\n const childMatch = childMatches.next(routeToSkip)\n if (!childMatch.done) {\n return {\n done: false,\n value: childMatch.value,\n }\n }\n\n childMatches = null\n childIndex++\n }\n }\n\n return { done: true }\n },\n }\n}\n\nexport default matchRoute\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nfunction resolveRoute(context, params) {\n if (typeof context.route.action === 'function') {\n return context.route.action(context, params)\n }\n return undefined\n}\n\nexport default resolveRoute\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nimport pathToRegexp from 'path-to-regexp'\nimport matchRoute from './matchRoute'\nimport resolveRoute from './resolveRoute'\nimport isChildRoute from './isChildRoute'\n\nclass UniversalRouter {\n constructor(routes, options = {}) {\n if (!routes || typeof routes !== 'object') {\n throw new TypeError('Invalid routes')\n }\n\n this.baseUrl = options.baseUrl || ''\n this.errorHandler = options.errorHandler\n this.resolveRoute = options.resolveRoute || resolveRoute\n this.context = { router: this, ...options.context }\n this.root = Array.isArray(routes) ? { path: '', children: routes, parent: null } : routes\n this.root.parent = null\n }\n\n resolve(pathnameOrContext) {\n const context = {\n ...this.context,\n ...(typeof pathnameOrContext === 'string'\n ? { pathname: pathnameOrContext }\n : pathnameOrContext),\n }\n const match = matchRoute(\n this.root,\n this.baseUrl,\n context.pathname.substr(this.baseUrl.length),\n [],\n null,\n )\n const resolve = this.resolveRoute\n let matches = null\n let nextMatches = null\n let currentContext = context\n\n function next(resume, parent = matches.value.route, prevResult) {\n const routeToSkip = prevResult === null && !matches.done && matches.value.route\n matches = nextMatches || match.next(routeToSkip)\n nextMatches = null\n\n if (!resume) {\n if (matches.done || !isChildRoute(parent, matches.value.route)) {\n nextMatches = matches\n return Promise.resolve(null)\n }\n }\n\n if (matches.done) {\n const error = new Error('Route not found')\n error.status = 404\n return Promise.reject(error)\n }\n\n currentContext = { ...context, ...matches.value }\n\n return Promise.resolve(resolve(currentContext, matches.value.params)).then((result) => {\n if (result !== null && result !== undefined) {\n return result\n }\n return next(resume, parent, result)\n })\n }\n\n context.next = next\n\n return Promise.resolve()\n .then(() => next(true, this.root))\n .catch((error) => {\n if (this.errorHandler) {\n return this.errorHandler(error, currentContext)\n }\n throw error\n })\n }\n}\n\nUniversalRouter.pathToRegexp = pathToRegexp\n\nexport default UniversalRouter\n","/**\n * Universal Router (https://www.kriasoft.com/universal-router/)\n *\n * Copyright (c) 2015-present Kriasoft.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.txt file in the root directory of this source tree.\n */\n\nfunction isChildRoute(parentRoute, childRoute) {\n let route = childRoute\n while (route) {\n route = route.parent\n if (route === parentRoute) {\n return true\n }\n }\n return false\n}\n\nexport default isChildRoute\n"],"names":["str","options","tokensToFunction","parse","pathToRegexp","tokensToRegExp","DEFAULT_DELIMITER","PATH_REGEXP","RegExp","join","res","group","tokens","key","index","path","defaultDelimiter","delimiter","whitelist","undefined","pathEscaped","exec","m","escaped","offset","slice","length","prev","name","capture","modifier","k","c","indexOf","push","repeat","optional","pattern","prefix","replace","escapeString","substr","matches","Array","i","flags","data","encode","encodeURIComponent","validate","token","segment","value","isArray","TypeError","j","test","String","sensitive","keys","strict","start","end","endsWith","concat","map","route","endToken","isEndDelimited","groups","source","match","regexpToRegexp","parts","arrayToRegexp","stringToRegexp","hasOwnProperty","Object","prototype","cache","Map","decodeParam","val","decodeURIComponent","err","matchRoute","baseUrl","pathname","parentKeys","parentParams","childMatches","childIndex","next","routeToSkip","done","children","cacheKey","regexp","get","set","params","prop","call","split","charAt","matchPath","childRoute","parent","childMatch","resolveRoute","context","action","UniversalRouter","resolve","pathnameOrContext","this","root","nextMatches","currentContext","resume","prevResult","parentRoute","isChildRoute","Promise","error","Error","status","reject","then","result","_this","errorHandler","routes","router"],"mappings":";qMAsHA,WAAkBA,EAAKC,UACdC,EAAiBC,EAAMH,EAAKC,GAAUA,GApH/C,MAAiBG,IACMD,IA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qF,SAAW,QAC7B6C,aAAelI,EAAQkI,kBACvBtB,aAAe5G,EAAQ4G,cAAgBA,OACvCC,uBAAYuB,OAAQlB,MAASlH,EAAQ6G,cACrCM,KAAOzE,MAAMU,QAAQ+E,GAAU,CAAErH,KAAM,GAAIgF,SAAUqC,EAAQzB,OAAQ,MAASyB,OAC9EhB,KAAKT,OAAS,YA+DvBK,EAAgB5G,aAAeA"} \ No newline at end of file diff --git a/package.json b/package.json index 4a90f3f..8249ca9 100644 --- a/package.json +++ b/package.json @@ -24,27 +24,27 @@ "esnext": "src/UniversalRouter.js", "types": "src/UniversalRouter.d.ts", "dependencies": { - "path-to-regexp": "^3.0.0" + "path-to-regexp": "^3.1.0" }, "devDependencies": { - "@babel/core": "7.5.5", - "@babel/preset-env": "7.5.5", - "@babel/register": "7.5.5", - "babel-jest": "^24.8.0", - "eslint": "^5.16.0", - "eslint-config-airbnb-base": "^13.2.0", - "eslint-config-prettier": "^6.0.0", - "eslint-plugin-import": "^2.18.1", + "@babel/core": "7.6.0", + "@babel/preset-env": "7.6.0", + "@babel/register": "7.6.0", + "babel-jest": "^24.9.0", + "eslint": "^6.4.0", + "eslint-config-airbnb-base": "^14.0.0", + "eslint-config-prettier": "^6.3.0", + "eslint-plugin-import": "^2.18.2", "fs-extra": "^8.1.0", - "husky": "^3.0.1", - "jest": "^24.8.0", + "husky": "^3.0.5", + "jest": "^24.9.0", "prettier": "^1.18.2", - "rollup": "^1.17.0", + "rollup": "^1.21.4", "rollup-plugin-babel": "^4.3.3", - "rollup-plugin-commonjs": "^10.0.1", + "rollup-plugin-commonjs": "^10.1.0", "rollup-plugin-node-resolve": "^5.2.0", - "rollup-plugin-uglify": "^6.0.2", - "typescript": "^3.5.3" + "rollup-plugin-uglify": "^6.0.3", + "typescript": "^3.6.3" }, "scripts": { "lint": "node tools/lint", diff --git a/src/generateUrls.d.ts b/src/generateUrls.d.ts index e7068b5..96cda76 100644 --- a/src/generateUrls.d.ts +++ b/src/generateUrls.d.ts @@ -7,18 +7,22 @@ * LICENSE.txt file in the root directory of this source tree. */ -import { PathFunctionOptions } from 'path-to-regexp' +import { PathFunctionOptions, TokensToFunctionOptions, ParseOptions } from 'path-to-regexp' import UniversalRouter from './UniversalRouter' +import UniversalRouterSync from './UniversalRouterSync' export interface Params { [paramName: string]: any } -export interface GenerateUrlsOptions extends PathFunctionOptions { +export interface GenerateUrlsOptions + extends PathFunctionOptions, + TokensToFunctionOptions, + ParseOptions { stringifyQueryParams?: (params: Params) => string } export default function generateUrls( - router: UniversalRouter, + router: UniversalRouter | UniversalRouterSync, options?: GenerateUrlsOptions, ): (routeName: string, params?: Params) => string diff --git a/src/generateUrls.js b/src/generateUrls.js index e2d52e0..399e53a 100644 --- a/src/generateUrls.js +++ b/src/generateUrls.js @@ -7,9 +7,8 @@ * LICENSE.txt file in the root directory of this source tree. */ -import UniversalRouter from './UniversalRouter' +import pathToRegexp from 'path-to-regexp' -const { pathToRegexp } = UniversalRouter const cache = new Map() function cacheRoutes(routesByName, route, routes) { @@ -31,8 +30,8 @@ function cacheRoutes(routesByName, route, routes) { } function generateUrls(router, options = {}) { - if (!(router instanceof UniversalRouter)) { - throw new TypeError('An instance of UniversalRouter is expected') + if (!router) { + throw new ReferenceError('Router is not defined') } router.routesByName = router.routesByName || new Map() @@ -60,8 +59,8 @@ function generateUrls(router, options = {}) { } rt = rt.parent } - const tokens = pathToRegexp.parse(fullPath) - const toPath = pathToRegexp.tokensToFunction(tokens) + const tokens = pathToRegexp.parse(fullPath, options) + const toPath = pathToRegexp.tokensToFunction(tokens, options) const keys = Object.create(null) for (let i = 0; i < tokens.length; i++) { if (typeof tokens[i] !== 'string') { diff --git a/test/generateUrls.test.js b/test/generateUrls.test.js index f7262ef..4d6a225 100644 --- a/test/generateUrls.test.js +++ b/test/generateUrls.test.js @@ -8,17 +8,12 @@ */ import UniversalRouter from '../src/UniversalRouter' +import UniversalRouterSync from '../src/UniversalRouterSync' import generateUrls from '../src/generateUrls' describe('generateUrls(router, options)(routeName, params)', () => { - it('should throw an error in case of invalid router', async () => { - expect(() => generateUrls()).toThrow(/An instance of UniversalRouter is expected/) - expect(() => generateUrls([])).toThrow(/An instance of UniversalRouter is expected/) - expect(() => generateUrls(123)).toThrow(/An instance of UniversalRouter is expected/) - expect(() => generateUrls(null)).toThrow(/An instance of UniversalRouter is expected/) - expect(() => generateUrls(UniversalRouter)).toThrow( - /An instance of UniversalRouter is expected/, - ) + it('should throw an error if router is not specified', async () => { + expect(() => generateUrls()).toThrow(/Router is not defined/) }) it('should throw an error if no route found', async () => { @@ -224,4 +219,10 @@ describe('generateUrls(router, options)(routeName, params)', () => { expect(stringifyQueryParams.mock.calls.length).toBe(1) expect(stringifyQueryParams.mock.calls[0][0]).toEqual({ x: 'i', y: 'j', z: 'k' }) }) + + it('should be compatible with UniversalRouterSync', async () => { + const router = new UniversalRouterSync({ path: '/foo', name: 'bar' }) + const url = generateUrls(router) + expect(url('bar')).toBe('/foo') + }) }) diff --git a/test/generateUrls.test.ts b/test/generateUrls.test.ts index 0834b29..6085057 100644 --- a/test/generateUrls.test.ts +++ b/test/generateUrls.test.ts @@ -8,7 +8,7 @@ */ import UniversalRouter from '../src/UniversalRouter' -import generateUrls, { Params } from '../src/generateUrls' +import generateUrls, { GenerateUrlsOptions, Params } from '../src/generateUrls' const router = new UniversalRouter( [ @@ -36,7 +36,7 @@ const path = generateUrls(router) path('home') // => '/base' -const options = { +const options: GenerateUrlsOptions = { encode: (value: string) => value, stringifyQueryParams(params: Params) { return Object.keys(params) diff --git a/tools/build.js b/tools/build.js index 13bbfe4..4fc5b7a 100644 --- a/tools/build.js +++ b/tools/build.js @@ -8,7 +8,6 @@ */ const fs = require('fs-extra') -const path = require('path') const rollup = require('rollup') const babel = require('rollup-plugin-babel') const { uglify } = require('rollup-plugin-uglify') @@ -78,33 +77,29 @@ const files = [ input: 'dist/src/generateUrls.js', output: 'dist/generateUrls/index.js', format: 'cjs', - external: ['path-to-regexp', path.resolve('dist/src/UniversalRouter.js')], - paths: { [path.resolve('dist/src/UniversalRouter.js')]: '..' }, + external: ['path-to-regexp'], }, { input: 'dist/src/generateUrls.js', output: 'dist/generateUrls/module.js', format: 'es', - external: ['path-to-regexp', path.resolve('dist/src/UniversalRouter.js')], - paths: { [path.resolve('dist/src/UniversalRouter.js')]: '..' }, + external: ['path-to-regexp'], }, { input: 'dist/src/generateUrls.js', output: 'dist/universal-router-generate-urls.js', format: 'umd', name: 'generateUrls', - external: ['path-to-regexp', './UniversalRouter'], - paths: { [path.resolve('dist/src/UniversalRouter')]: './universal-router.js' }, - globals: { [path.resolve('dist/src/UniversalRouter')]: 'UniversalRouter' }, + external: ['path-to-regexp'], + globals: { 'path-to-regexp': 'UniversalRouter.pathToRegexp' }, }, { input: 'dist/src/generateUrls.js', output: 'dist/universal-router-generate-urls.min.js', format: 'umd', name: 'generateUrls', - external: ['path-to-regexp', './UniversalRouter'], - paths: { [path.resolve('dist/src/UniversalRouter')]: './universal-router.min.js' }, - globals: { [path.resolve('dist/src/UniversalRouter')]: 'UniversalRouter' }, + external: ['path-to-regexp'], + globals: { 'path-to-regexp': 'UniversalRouter.pathToRegexp' }, }, ] @@ -155,7 +150,6 @@ async function build() { banner: '/*! Universal Router | MIT License | https://www.kriasoft.com/universal-router/ */\n', globals: file.globals, - paths: file.paths, }) }), )