@tanstack/react-router 1.81.4 → 1.81.5
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 +22 -5
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/esm/router.js +22 -5
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/router.ts +23 -5
package/dist/cjs/router.cjs
CHANGED
|
@@ -350,8 +350,8 @@ class Router {
|
|
|
350
350
|
decodeCharMap: this.pathParamsDecodeCharMap
|
|
351
351
|
});
|
|
352
352
|
let search = fromSearch;
|
|
353
|
-
if (opts._includeValidateSearch) {
|
|
354
|
-
let validatedSearch =
|
|
353
|
+
if (opts._includeValidateSearch && ((_f = this.options.search) == null ? void 0 : _f.strict)) {
|
|
354
|
+
let validatedSearch = {};
|
|
355
355
|
matchedRoutesResult == null ? void 0 : matchedRoutesResult.matchedRoutes.forEach((route) => {
|
|
356
356
|
try {
|
|
357
357
|
if (route.options.validateSearch) {
|
|
@@ -372,10 +372,10 @@ class Router {
|
|
|
372
372
|
const allMiddlewares = (matchedRoutesResult == null ? void 0 : matchedRoutesResult.matchedRoutes.reduce(
|
|
373
373
|
(acc, route) => {
|
|
374
374
|
var _a2;
|
|
375
|
-
|
|
375
|
+
const middlewares = [];
|
|
376
376
|
if ("search" in route.options) {
|
|
377
377
|
if ((_a2 = route.options.search) == null ? void 0 : _a2.middlewares) {
|
|
378
|
-
middlewares
|
|
378
|
+
middlewares.push(...route.options.search.middlewares);
|
|
379
379
|
}
|
|
380
380
|
} else if (route.options.preSearchFilters || route.options.postSearchFilters) {
|
|
381
381
|
const legacyMiddleware = ({
|
|
@@ -398,7 +398,24 @@ class Router {
|
|
|
398
398
|
}
|
|
399
399
|
return result;
|
|
400
400
|
};
|
|
401
|
-
middlewares
|
|
401
|
+
middlewares.push(legacyMiddleware);
|
|
402
|
+
}
|
|
403
|
+
if (opts._includeValidateSearch && route.options.validateSearch) {
|
|
404
|
+
const validate = ({ search: search3, next }) => {
|
|
405
|
+
try {
|
|
406
|
+
const result = next(search3);
|
|
407
|
+
const validatedSearch = {
|
|
408
|
+
...result,
|
|
409
|
+
...validateSearch(
|
|
410
|
+
route.options.validateSearch,
|
|
411
|
+
result
|
|
412
|
+
) ?? {}
|
|
413
|
+
};
|
|
414
|
+
return validatedSearch;
|
|
415
|
+
} catch (e) {
|
|
416
|
+
}
|
|
417
|
+
};
|
|
418
|
+
middlewares.push(validate);
|
|
402
419
|
}
|
|
403
420
|
return acc.concat(middlewares);
|
|
404
421
|
},
|