Explorar o código

order catch all routes after non-catch all routes

Evan Almloff %!s(int64=2) %!d(string=hai) anos
pai
achega
be3dae4b05
Modificáronse 1 ficheiros con 7 adicións e 1 borrados
  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,
+                    }
+                }
             }
         });
     }