Browse Source

order catch all routes after non-catch all routes

Evan Almloff 2 years ago
parent
commit
be3dae4b05
1 changed files with 7 additions and 1 deletions
  1. 7 1
      packages/router-macro/src/route_tree.rs

+ 7 - 1
packages/router-macro/src/route_tree.rs

@@ -40,7 +40,13 @@ impl<'a> RouteTree<'a> {
             match seg {
                 RouteTreeSegmentData::Static { .. } => 0,
                 RouteTreeSegmentData::Layout { .. } => 1,
-                RouteTreeSegmentData::Route(_) => 1,
+                RouteTreeSegmentData::Route(route) => {
+                    // Routes that end in a catch all segment should be checked last
+                    match route.segments.last() {
+                        Some(RouteSegment::CatchAll(..)) => 2,
+                        _ => 1,
+                    }
+                }
             }
         });
     }