Skip to content

Commit

Permalink
Fix ScopedRouter not matching current paths with query
Browse files Browse the repository at this point in the history
  • Loading branch information
charlag committed Sep 2, 2024
1 parent cb35f9b commit 8746b77
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/common/gui/ScopedRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ export class ScopedRouter<Scope extends string> implements Router {
}

export function routeMatchesPrefix(prefixWithoutLeadingSlash: string, route: string): boolean {
return route.split("/")[1] === prefixWithoutLeadingSlash
const { path } = m.parsePathname(route)
return path.split("/")[1] === prefixWithoutLeadingSlash
}
4 changes: 4 additions & 0 deletions test/tests/gui/ScopedRouterTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,9 @@ o.spec("ScopedRouter", function () {
o("does not match empty", function () {
o(routeMatchesPrefix("contact", "/")).equals(false)
})

o("route with query matches prefix", function () {
o(routeMatchesPrefix("contact", "/contact?test=1")).equals(true)
})
})
})

0 comments on commit 8746b77

Please sign in to comment.