Skip to content

Commit 82fbe32

Browse files
committed
Correctly handle pathless route in hasCatchAll.
1 parent 55cfe54 commit 82fbe32

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

packages/ra-router-tanstack/src/tanStackRouterProvider.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -650,8 +650,8 @@ const Routes = ({ children, location: locationProp }: RouterRoutesProps) => {
650650
const parentParams = React.useContext(ParamsContext);
651651

652652
// Check if a route pattern has a catch-all at the end
653-
const hasCatchAll = (path: string): boolean => {
654-
return path.endsWith('/*') || path === '*';
653+
const hasCatchAll = (path: string | undefined): boolean => {
654+
return !path || path.endsWith('/*') || path === '*';
655655
};
656656

657657
// Check if routeB is more specific than routeA when both match the same path
@@ -760,7 +760,7 @@ const Routes = ({ children, location: locationProp }: RouterRoutesProps) => {
760760
};
761761

762762
// If this match doesn't use a catch-all, return immediately
763-
if (!hasCatchAll(bestMatch.route.path!)) {
763+
if (!hasCatchAll(bestMatch.route.path)) {
764764
return routeForBestMatch;
765765
}
766766
// Otherwise, keep looking for more specific matches

0 commit comments

Comments
 (0)