@bugsnag/vue-router-performance
Advanced tools
Comparing version
import { onSettle } from '@bugsnag/browser-performance'; | ||
import pathToRegexp from 'path-to-regexp'; | ||
function flattenRoutes(routes, _prefix = '') { | ||
const prefix = `${!_prefix || _prefix === '/' ? _prefix : `${_prefix}/`}`; | ||
return [ | ||
...routes.map(route => `${prefix}${route.path || ''}`), | ||
...routes.reduce((accum, route) => [...accum, ...(route.children ? flattenRoutes(route.children, `${prefix}${route.path}`) : [])], []) | ||
]; | ||
} | ||
class VueRouterRoutingProvider { | ||
@@ -16,3 +8,5 @@ constructor(router, basename) { | ||
function resolveRoute(url) { | ||
return flattenRoutes(router.getRoutes()).find((fullRoutePath) => url.pathname.replace(normalizedBasename !== null && normalizedBasename !== void 0 ? normalizedBasename : '', '').match(pathToRegexp(fullRoutePath))) || 'no-route-found'; | ||
var _a; | ||
const location = router.resolve({ path: url.pathname.replace(normalizedBasename !== null && normalizedBasename !== void 0 ? normalizedBasename : '', '') }); | ||
return ((_a = location.matched.pop()) === null || _a === void 0 ? void 0 : _a.path) || 'no-route-found'; | ||
} | ||
@@ -19,0 +13,0 @@ this.resolveRoute = resolveRoute; |
{ | ||
"name": "@bugsnag/vue-router-performance", | ||
"version": "2.7.1", | ||
"version": "2.8.0", | ||
"description": "BugSnag performance monitoring for vue-router", | ||
@@ -24,3 +24,2 @@ "homepage": "https://www.bugsnag.com/", | ||
"@bugsnag/browser-performance": "*", | ||
"path-to-regexp": "^1.8.0", | ||
"vue-router": "^4.2.4" | ||
@@ -34,3 +33,3 @@ }, | ||
], | ||
"gitHead": "1358bf6082aa354fd49249c700ca9e486cad3681" | ||
"gitHead": "39754ecb88063ec84edb031202820545950725de" | ||
} |
Sorry, the diff of this file is not supported yet
2
-33.33%5075
-6.83%37
-13.95%