@tanstack/router-core 1.154.8 → 1.154.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/router.cjs +28 -23
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/esm/router.js +28 -23
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/router.ts +44 -28
package/dist/esm/router.js
CHANGED
|
@@ -314,14 +314,21 @@ class RouterCore {
|
|
|
314
314
|
path: nextTo,
|
|
315
315
|
params: nextParams
|
|
316
316
|
}).interpolatedPath;
|
|
317
|
-
const
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
);
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
317
|
+
const destMatchResult = this.getMatchedRoutes(interpolatedNextTo);
|
|
318
|
+
let destRoutes = destMatchResult.matchedRoutes;
|
|
319
|
+
const rawParams = destMatchResult.routeParams;
|
|
320
|
+
const isGlobalNotFound = destMatchResult.foundRoute ? destMatchResult.foundRoute.path !== "/" && destMatchResult.routeParams["**"] : trimPathRight(interpolatedNextTo);
|
|
321
|
+
let globalNotFoundRouteId;
|
|
322
|
+
if (isGlobalNotFound) {
|
|
323
|
+
if (this.options.notFoundRoute) {
|
|
324
|
+
destRoutes = [...destRoutes, this.options.notFoundRoute];
|
|
325
|
+
} else {
|
|
326
|
+
globalNotFoundRouteId = findGlobalNotFoundRouteId(
|
|
327
|
+
this.options.notFoundMode,
|
|
328
|
+
destRoutes
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
325
332
|
if (Object.keys(nextParams).length > 0) {
|
|
326
333
|
for (const route of destRoutes) {
|
|
327
334
|
const fn = route.options.params?.stringify ?? route.options.stringifyParams;
|
|
@@ -380,7 +387,7 @@ class RouterCore {
|
|
|
380
387
|
routes: destRoutes,
|
|
381
388
|
params: snapshotParams,
|
|
382
389
|
searchStr,
|
|
383
|
-
globalNotFoundRouteId
|
|
390
|
+
globalNotFoundRouteId
|
|
384
391
|
});
|
|
385
392
|
const fullPath = `${nextPathname}${searchStr}${hashStr}`;
|
|
386
393
|
const url = new URL(fullPath, this.origin);
|
|
@@ -1104,20 +1111,7 @@ class RouterCore {
|
|
|
1104
1111
|
isGlobalNotFound = true;
|
|
1105
1112
|
}
|
|
1106
1113
|
}
|
|
1107
|
-
globalNotFoundRouteId = (
|
|
1108
|
-
if (!isGlobalNotFound) {
|
|
1109
|
-
return void 0;
|
|
1110
|
-
}
|
|
1111
|
-
if (this.options.notFoundMode !== "root") {
|
|
1112
|
-
for (let i = matchedRoutes.length - 1; i >= 0; i--) {
|
|
1113
|
-
const route = matchedRoutes[i];
|
|
1114
|
-
if (route.children) {
|
|
1115
|
-
return route.id;
|
|
1116
|
-
}
|
|
1117
|
-
}
|
|
1118
|
-
}
|
|
1119
|
-
return rootRouteId;
|
|
1120
|
-
})();
|
|
1114
|
+
globalNotFoundRouteId = isGlobalNotFound ? findGlobalNotFoundRouteId(this.options.notFoundMode, matchedRoutes) : void 0;
|
|
1121
1115
|
}
|
|
1122
1116
|
const matches = [];
|
|
1123
1117
|
const getParentContext = (parentMatch) => {
|
|
@@ -1517,6 +1511,17 @@ function applySearchMiddleware({
|
|
|
1517
1511
|
};
|
|
1518
1512
|
return applyNext(0, search);
|
|
1519
1513
|
}
|
|
1514
|
+
function findGlobalNotFoundRouteId(notFoundMode, routes) {
|
|
1515
|
+
if (notFoundMode !== "root") {
|
|
1516
|
+
for (let i = routes.length - 1; i >= 0; i--) {
|
|
1517
|
+
const route = routes[i];
|
|
1518
|
+
if (route.children) {
|
|
1519
|
+
return route.id;
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
return rootRouteId;
|
|
1524
|
+
}
|
|
1520
1525
|
export {
|
|
1521
1526
|
PathParamError,
|
|
1522
1527
|
RouterCore,
|