@tanstack/router-core 1.131.23 → 1.131.24

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/src/router.ts CHANGED
@@ -1471,20 +1471,20 @@ export class RouterCore<
1471
1471
  : this.resolvePathWithBase(fromPath, '.')
1472
1472
 
1473
1473
  // Resolve the next params
1474
- let nextParams =
1474
+ const nextParams =
1475
1475
  dest.params === false || dest.params === null
1476
1476
  ? {}
1477
1477
  : (dest.params ?? true) === true
1478
1478
  ? fromParams
1479
- : {
1480
- ...fromParams,
1481
- ...functionalUpdate(dest.params as any, fromParams),
1482
- }
1479
+ : Object.assign(
1480
+ fromParams,
1481
+ functionalUpdate(dest.params as any, fromParams),
1482
+ )
1483
1483
 
1484
1484
  // Interpolate the path first to get the actual resolved path, then match against that
1485
1485
  const interpolatedNextTo = interpolatePath({
1486
1486
  path: nextTo,
1487
- params: nextParams ?? {},
1487
+ params: nextParams,
1488
1488
  parseCache: this.parsePathnameCache,
1489
1489
  }).interpolatedPath
1490
1490
 
@@ -1494,23 +1494,20 @@ export class RouterCore<
1494
1494
 
1495
1495
  // If there are any params, we need to stringify them
1496
1496
  if (Object.keys(nextParams).length > 0) {
1497
- destRoutes
1498
- .map((route) => {
1499
- return (
1500
- route.options.params?.stringify ?? route.options.stringifyParams
1501
- )
1502
- })
1503
- .filter(Boolean)
1504
- .forEach((fn) => {
1505
- nextParams = { ...nextParams!, ...fn!(nextParams) }
1506
- })
1497
+ for (const route of destRoutes) {
1498
+ const fn =
1499
+ route.options.params?.stringify ?? route.options.stringifyParams
1500
+ if (fn) {
1501
+ Object.assign(nextParams, fn(nextParams))
1502
+ }
1503
+ }
1507
1504
  }
1508
1505
 
1509
1506
  const nextPathname = interpolatePath({
1510
1507
  // Use the original template path for interpolation
1511
1508
  // This preserves the original parameter syntax including optional parameters
1512
1509
  path: nextTo,
1513
- params: nextParams ?? {},
1510
+ params: nextParams,
1514
1511
  leaveWildcards: false,
1515
1512
  leaveParams: opts.leaveParams,
1516
1513
  decodeCharMap: this.pathParamsDecodeCharMap,
@@ -1520,20 +1517,20 @@ export class RouterCore<
1520
1517
  // Resolve the next search
1521
1518
  let nextSearch = fromSearch
1522
1519
  if (opts._includeValidateSearch && this.options.search?.strict) {
1523
- let validatedSearch = {}
1520
+ const validatedSearch = {}
1524
1521
  destRoutes.forEach((route) => {
1525
- try {
1526
- if (route.options.validateSearch) {
1527
- validatedSearch = {
1528
- ...validatedSearch,
1529
- ...(validateSearch(route.options.validateSearch, {
1522
+ if (route.options.validateSearch) {
1523
+ try {
1524
+ Object.assign(
1525
+ validatedSearch,
1526
+ validateSearch(route.options.validateSearch, {
1530
1527
  ...validatedSearch,
1531
1528
  ...nextSearch,
1532
- }) ?? {}),
1533
- }
1529
+ }),
1530
+ )
1531
+ } catch {
1532
+ // ignore errors here because they are already handled in matchRoutes
1534
1533
  }
1535
- } catch {
1536
- // ignore errors here because they are already handled in matchRoutes
1537
1534
  }
1538
1535
  })
1539
1536
  nextSearch = validatedSearch