Skip to content

Commit

Permalink
simplify router logic
Browse files Browse the repository at this point in the history
  • Loading branch information
LankyMoose committed Feb 24, 2024
1 parent 2ef5f42 commit bc7fa3d
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions packages/lib/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,22 @@ function Router(props: RouterProps) {

let fallbackRoute: RouteComponent | undefined
for (const child of props.children ?? []) {
if (isRoute(child)) {
if (isFallbackRoute(child)) {
fallbackRoute = child
continue
}
const routeSegments = ((props.basePath || "") + child.props.path).split(
"/"
)
const params = matchPath(routeSegments, pathSegments)
if (params) {
return fragment({
children: [createElement(child.props.element, { params, query })],
})
}
if (!isRoute(child)) continue

if (isFallbackRoute(child)) {
fallbackRoute = child
continue
}

const routeSegments = ((props.basePath || "") + child.props.path).split("/")
const params = matchPath(routeSegments, pathSegments)
if (params) {
return fragment({
children: [createElement(child.props.element, { params, query })],
})
}
}

if (fallbackRoute) {
return fragment({
children: [
Expand Down

0 comments on commit bc7fa3d

Please sign in to comment.