@tanstack/router-core 1.135.2 → 1.136.1

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/path.ts CHANGED
@@ -377,7 +377,6 @@ function baseParsePathname(pathname: string): ReadonlyArray<Segment> {
377
377
  interface InterpolatePathOptions {
378
378
  path?: string
379
379
  params: Record<string, unknown>
380
- leaveParams?: boolean
381
380
  // Map of encoded chars to decoded chars (e.g. '%40' -> '@') that should remain decoded in path params
382
381
  decodeCharMap?: Map<string, string>
383
382
  parseCache?: ParsePathnameCache
@@ -393,7 +392,6 @@ type InterPolatePathResult = {
393
392
  *
394
393
  * - Encodes params safely (configurable allowed characters)
395
394
  * - Supports `{-$optional}` segments, `{prefix{$id}suffix}` and `{$}` wildcards
396
- * - Optionally leaves placeholders or wildcards in place
397
395
  */
398
396
  /**
399
397
  * Interpolate params and wildcards into a route path template.
@@ -402,7 +400,6 @@ type InterPolatePathResult = {
402
400
  export function interpolatePath({
403
401
  path,
404
402
  params,
405
- leaveParams,
406
403
  decodeCharMap,
407
404
  parseCache,
408
405
  }: InterpolatePathOptions): InterPolatePathResult {
@@ -452,6 +449,7 @@ export function interpolatePath({
452
449
  }
453
450
 
454
451
  const value = encodeParam('_splat')
452
+
455
453
  return `${segmentPrefix}${value}${segmentSuffix}`
456
454
  }
457
455
 
@@ -464,10 +462,7 @@ export function interpolatePath({
464
462
 
465
463
  const segmentPrefix = segment.prefixSegment || ''
466
464
  const segmentSuffix = segment.suffixSegment || ''
467
- if (leaveParams) {
468
- const value = encodeParam(segment.value)
469
- return `${segmentPrefix}${segment.value}${value ?? ''}${segmentSuffix}`
470
- }
465
+
471
466
  return `${segmentPrefix}${encodeParam(key) ?? 'undefined'}${segmentSuffix}`
472
467
  }
473
468
 
@@ -489,10 +484,6 @@ export function interpolatePath({
489
484
 
490
485
  usedParams[key] = params[key]
491
486
 
492
- if (leaveParams) {
493
- const value = encodeParam(segment.value)
494
- return `${segmentPrefix}${segment.value}${value ?? ''}${segmentSuffix}`
495
- }
496
487
  return `${segmentPrefix}${encodeParam(key) ?? ''}${segmentSuffix}`
497
488
  }
498
489
 
package/src/router.ts CHANGED
@@ -1683,17 +1683,18 @@ export class RouterCore<
1683
1683
  }
1684
1684
  }
1685
1685
 
1686
- const nextPathname = decodePath(
1687
- interpolatePath({
1688
- // Use the original template path for interpolation
1686
+ const nextPathname = opts.leaveParams
1687
+ ? // Use the original template path for interpolation
1689
1688
  // This preserves the original parameter syntax including optional parameters
1690
- path: nextTo,
1691
- params: nextParams,
1692
- leaveParams: opts.leaveParams,
1693
- decodeCharMap: this.pathParamsDecodeCharMap,
1694
- parseCache: this.parsePathnameCache,
1695
- }).interpolatedPath,
1696
- )
1689
+ nextTo
1690
+ : decodePath(
1691
+ interpolatePath({
1692
+ path: nextTo,
1693
+ params: nextParams,
1694
+ decodeCharMap: this.pathParamsDecodeCharMap,
1695
+ parseCache: this.parsePathnameCache,
1696
+ }).interpolatedPath,
1697
+ )
1697
1698
 
1698
1699
  // Resolve the next search
1699
1700
  let nextSearch = fromSearch