1
0
Fork 0
mirror of synced 2024-10-02 18:16:29 +13:00

Merge pull request #746 from Budibase/mike-fixes

Mike fixes
This commit is contained in:
Michael Shanks 2020-10-17 08:49:59 +01:00 committed by GitHub
commit 77ed92b444
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View file

@ -4,7 +4,7 @@ export default function(url) {
.map(part => { .map(part => {
// if parameter, then use as is // if parameter, then use as is
if (part.startsWith(":")) return part if (part.startsWith(":")) return part
return encodeURIComponent(part.replace(" ", "-")) return encodeURIComponent(part.replace(/ /g, "-"))
}) })
.join("/") .join("/")
.toLowerCase() .toLowerCase()

View file

@ -44,7 +44,7 @@ export const screenRouter = ({ screens, onScreenSelected, window }) => {
} }
const routes = screens.map(s => makeRootedPath(s.route)) 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 if (fallback < 0) fallback = 0
let current let current
@ -53,7 +53,7 @@ export const screenRouter = ({ screens, onScreenSelected, window }) => {
const _url = makeRootedPath(url.state || url) const _url = makeRootedPath(url.state || url)
current = routes.findIndex( current = routes.findIndex(
p => p =>
p !== "*" && p !== makeRootedPath("*") &&
new RegExp("^" + p.toLowerCase() + "$").test(_url.toLowerCase()) new RegExp("^" + p.toLowerCase() + "$").test(_url.toLowerCase())
) )
@ -61,6 +61,8 @@ export const screenRouter = ({ screens, onScreenSelected, window }) => {
if (current === -1) { if (current === -1) {
routes.forEach((p, i) => { routes.forEach((p, i) => {
// ignore home - which matched everything
if (p === makeRootedPath("*")) return
const pm = regexparam(p) const pm = regexparam(p)
const matches = pm.pattern.exec(_url) const matches = pm.pattern.exec(_url)