From 1a8c2907ca32a086a7598013a3cbe1bbd9da3227 Mon Sep 17 00:00:00 2001 From: Michael Shanks Date: Fri, 16 Oct 2020 23:36:16 +0100 Subject: [PATCH] fixes home route matching everything --- packages/client/src/render/screenRouter.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/client/src/render/screenRouter.js b/packages/client/src/render/screenRouter.js index 3bfc85caaf..0c045097ed 100644 --- a/packages/client/src/render/screenRouter.js +++ b/packages/client/src/render/screenRouter.js @@ -44,7 +44,7 @@ export const screenRouter = ({ screens, onScreenSelected, window }) => { } const routes = screens.map(s => makeRootedPath(s.route)) - let fallback = routes.findIndex(([p]) => p === "*") + let fallback = routes.findIndex(([p]) => p === makeRootedPath("*")) if (fallback < 0) fallback = 0 let current @@ -53,7 +53,7 @@ export const screenRouter = ({ screens, onScreenSelected, window }) => { const _url = makeRootedPath(url.state || url) current = routes.findIndex( p => - p !== "*" && + p !== makeRootedPath("*") && new RegExp("^" + p.toLowerCase() + "$").test(_url.toLowerCase()) ) @@ -61,6 +61,8 @@ export const screenRouter = ({ screens, onScreenSelected, window }) => { if (current === -1) { routes.forEach((p, i) => { + // ignore home - which matched everything + if (p === makeRootedPath("*")) return const pm = regexparam(p) const matches = pm.pattern.exec(_url)