@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.
@@ -348,8 +348,8 @@ class Router {
348
348
  decodeCharMap: this.pathParamsDecodeCharMap
349
349
  });
350
350
  let search = fromSearch;
351
- if (opts._includeValidateSearch) {
352
- let validatedSearch = ((_f = this.options.search) == null ? void 0 : _f.strict) ? {} : search;
351
+ if (opts._includeValidateSearch && ((_f = this.options.search) == null ? void 0 : _f.strict)) {
352
+ let validatedSearch = {};
353
353
  matchedRoutesResult == null ? void 0 : matchedRoutesResult.matchedRoutes.forEach((route) => {
354
354
  try {
355
355
  if (route.options.validateSearch) {
@@ -370,10 +370,10 @@ class Router {
370
370
  const allMiddlewares = (matchedRoutesResult == null ? void 0 : matchedRoutesResult.matchedRoutes.reduce(
371
371
  (acc, route) => {
372
372
  var _a2;
373
- let middlewares = [];
373
+ const middlewares = [];
374
374
  if ("search" in route.options) {
375
375
  if ((_a2 = route.options.search) == null ? void 0 : _a2.middlewares) {
376
- middlewares = route.options.search.middlewares;
376
+ middlewares.push(...route.options.search.middlewares);
377
377
  }
378
378
  } else if (route.options.preSearchFilters || route.options.postSearchFilters) {
379
379
  const legacyMiddleware = ({
@@ -396,7 +396,24 @@ class Router {
396
396
  }
397
397
  return result;
398
398
  };
399
- middlewares = [legacyMiddleware];
399
+ middlewares.push(legacyMiddleware);
400
+ }
401
+ if (opts._includeValidateSearch && route.options.validateSearch) {
402
+ const validate = ({ search: search3, next }) => {
403
+ try {
404
+ const result = next(search3);
405
+ const validatedSearch = {
406
+ ...result,
407
+ ...validateSearch(
408
+ route.options.validateSearch,
409
+ result
410
+ ) ?? {}
411
+ };
412
+ return validatedSearch;
413
+ } catch (e) {
414
+ }
415
+ };
416
+ middlewares.push(validate);
400
417
  }
401
418
  return acc.concat(middlewares);
402
419
  },