mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Reduce route lookups
This commit is contained in:
parent
f625915540
commit
2737399bbf
1 changed files with 12 additions and 12 deletions
|
@ -144,18 +144,18 @@ class AppRouter {
|
||||||
// Strip the leading "!" if present
|
// Strip the leading "!" if present
|
||||||
const normalizedPath = location.pathname.replace(/^!/, '');
|
const normalizedPath = location.pathname.replace(/^!/, '');
|
||||||
|
|
||||||
if (this.allRoutes.has(normalizedPath)) {
|
const route = this.allRoutes.get(normalizedPath);
|
||||||
console.debug('[appRouter] "%s" route found', normalizedPath, location, this.allRoutes.get(normalizedPath));
|
if (route) {
|
||||||
this.allRoutes.get(normalizedPath)
|
console.debug('[appRouter] "%s" route found', normalizedPath, location, route);
|
||||||
.handler({
|
route.handler({
|
||||||
// Recreate the default context used by page.js: https://github.com/visionmedia/page.js#context
|
// Recreate the default context used by page.js: https://github.com/visionmedia/page.js#context
|
||||||
path: normalizedPath + location.search,
|
path: normalizedPath + location.search,
|
||||||
pathname: normalizedPath,
|
pathname: normalizedPath,
|
||||||
querystring: location.search.replace(/^\?/, ''),
|
querystring: location.search.replace(/^\?/, ''),
|
||||||
state: location.state,
|
state: location.state,
|
||||||
// Custom context variables
|
// Custom context variables
|
||||||
isBack: action === Action.Pop
|
isBack: action === Action.Pop
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.warn('[appRouter] "%s" route not found', normalizedPath, location);
|
console.warn('[appRouter] "%s" route not found', normalizedPath, location);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue