@@ -4157,7 +4157,7 @@ function useFalconApiContext() {
41574157}
41584158
41594159/**
4160- * react-router v7.8.0
4160+ * react-router v7.8.1
41614161 *
41624162 * Copyright (c) Remix Software Inc.
41634163 *
@@ -4232,15 +4232,18 @@ function matchRoutesImpl(routes, locationArg, basename, allowPartial) {
42324232 }
42334233 return matches;
42344234}
4235- function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "") {
4236- let flattenRoute = (route, index, relativePath) => {
4235+ function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "", _hasParentOptionalSegments = false ) {
4236+ let flattenRoute = (route, index, hasParentOptionalSegments = _hasParentOptionalSegments, relativePath) => {
42374237 let meta = {
42384238 relativePath: relativePath === void 0 ? route.path || "" : relativePath,
42394239 caseSensitive: route.caseSensitive === true,
42404240 childrenIndex: index,
42414241 route
42424242 };
42434243 if (meta.relativePath.startsWith("/")) {
4244+ if (!meta.relativePath.startsWith(parentPath) && hasParentOptionalSegments) {
4245+ return;
4246+ }
42444247 invariant(
42454248 meta.relativePath.startsWith(parentPath),
42464249 `Absolute route path "${meta.relativePath}" nested under path "${parentPath}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`
@@ -4256,7 +4259,13 @@ function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "")
42564259 route.index !== true,
42574260 `Index routes must not have child routes. Please remove all child routes from route path "${path}".`
42584261 );
4259- flattenRoutes(route.children, branches, routesMeta, path);
4262+ flattenRoutes(
4263+ route.children,
4264+ branches,
4265+ routesMeta,
4266+ path,
4267+ hasParentOptionalSegments
4268+ );
42604269 }
42614270 if (route.path == null && !route.index) {
42624271 return;
@@ -4272,7 +4281,7 @@ function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "")
42724281 flattenRoute(route, index);
42734282 } else {
42744283 for (let exploded of explodeOptionalSegments(route.path)) {
4275- flattenRoute(route, index, exploded);
4284+ flattenRoute(route, index, true, exploded);
42764285 }
42774286 }
42784287 });
@@ -4436,7 +4445,7 @@ function compilePath(path, caseSensitive = false, end = true) {
44364445 params.push({ paramName, isOptional: isOptional != null });
44374446 return isOptional ? "/?([^\\/]+)?" : "/([^\\/]+)";
44384447 }
4439- );
4448+ ).replace(/\/([\w-]+)\?(\/|$)/g, "(/$1)?$2") ;
44404449 if (path.endsWith("*")) {
44414450 params.push({ paramName: "*" });
44424451 regexpSource += path === "*" || path === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$";
@@ -5538,7 +5547,7 @@ var isBrowser = typeof window !== "undefined" && typeof window.document !== "und
55385547try {
55395548 if (isBrowser) {
55405549 window.__reactRouterVersion = // @ts-expect-error
5541- "7.8.0 ";
5550+ "7.8.1 ";
55425551 }
55435552} catch (e) {
55445553}
0 commit comments