@tanstack/router-core 1.134.20 → 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/dist/cjs/load-matches.cjs +1 -1
- package/dist/cjs/load-matches.cjs.map +1 -1
- package/dist/cjs/path.cjs +0 -22
- package/dist/cjs/path.cjs.map +1 -1
- package/dist/cjs/path.d.cts +1 -4
- package/dist/cjs/router.cjs +11 -12
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/esm/load-matches.js +1 -1
- package/dist/esm/load-matches.js.map +1 -1
- package/dist/esm/path.d.ts +1 -4
- package/dist/esm/path.js +0 -22
- package/dist/esm/path.js.map +1 -1
- package/dist/esm/router.js +11 -12
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/load-matches.ts +1 -1
- package/src/path.ts +2 -25
- package/src/router.ts +17 -18
package/src/load-matches.ts
CHANGED
package/src/path.ts
CHANGED
|
@@ -377,8 +377,6 @@ function baseParsePathname(pathname: string): ReadonlyArray<Segment> {
|
|
|
377
377
|
interface InterpolatePathOptions {
|
|
378
378
|
path?: string
|
|
379
379
|
params: Record<string, unknown>
|
|
380
|
-
leaveWildcards?: boolean
|
|
381
|
-
leaveParams?: boolean
|
|
382
380
|
// Map of encoded chars to decoded chars (e.g. '%40' -> '@') that should remain decoded in path params
|
|
383
381
|
decodeCharMap?: Map<string, string>
|
|
384
382
|
parseCache?: ParsePathnameCache
|
|
@@ -394,7 +392,6 @@ type InterPolatePathResult = {
|
|
|
394
392
|
*
|
|
395
393
|
* - Encodes params safely (configurable allowed characters)
|
|
396
394
|
* - Supports `{-$optional}` segments, `{prefix{$id}suffix}` and `{$}` wildcards
|
|
397
|
-
* - Optionally leaves placeholders or wildcards in place
|
|
398
395
|
*/
|
|
399
396
|
/**
|
|
400
397
|
* Interpolate params and wildcards into a route path template.
|
|
@@ -403,8 +400,6 @@ type InterPolatePathResult = {
|
|
|
403
400
|
export function interpolatePath({
|
|
404
401
|
path,
|
|
405
402
|
params,
|
|
406
|
-
leaveWildcards,
|
|
407
|
-
leaveParams,
|
|
408
403
|
decodeCharMap,
|
|
409
404
|
parseCache,
|
|
410
405
|
}: InterpolatePathOptions): InterPolatePathResult {
|
|
@@ -446,9 +441,6 @@ export function interpolatePath({
|
|
|
446
441
|
if (!params._splat) {
|
|
447
442
|
isMissingParams = true
|
|
448
443
|
// For missing splat parameters, just return the prefix and suffix without the wildcard
|
|
449
|
-
if (leaveWildcards) {
|
|
450
|
-
return `${segmentPrefix}${segment.value}${segmentSuffix}`
|
|
451
|
-
}
|
|
452
444
|
// If there is a prefix or suffix, return them joined, otherwise omit the segment
|
|
453
445
|
if (segmentPrefix || segmentSuffix) {
|
|
454
446
|
return `${segmentPrefix}${segmentSuffix}`
|
|
@@ -457,9 +449,7 @@ export function interpolatePath({
|
|
|
457
449
|
}
|
|
458
450
|
|
|
459
451
|
const value = encodeParam('_splat')
|
|
460
|
-
|
|
461
|
-
return `${segmentPrefix}${segment.value}${value ?? ''}${segmentSuffix}`
|
|
462
|
-
}
|
|
452
|
+
|
|
463
453
|
return `${segmentPrefix}${value}${segmentSuffix}`
|
|
464
454
|
}
|
|
465
455
|
|
|
@@ -472,10 +462,7 @@ export function interpolatePath({
|
|
|
472
462
|
|
|
473
463
|
const segmentPrefix = segment.prefixSegment || ''
|
|
474
464
|
const segmentSuffix = segment.suffixSegment || ''
|
|
475
|
-
|
|
476
|
-
const value = encodeParam(segment.value)
|
|
477
|
-
return `${segmentPrefix}${segment.value}${value ?? ''}${segmentSuffix}`
|
|
478
|
-
}
|
|
465
|
+
|
|
479
466
|
return `${segmentPrefix}${encodeParam(key) ?? 'undefined'}${segmentSuffix}`
|
|
480
467
|
}
|
|
481
468
|
|
|
@@ -487,9 +474,6 @@ export function interpolatePath({
|
|
|
487
474
|
|
|
488
475
|
// Check if optional parameter is missing or undefined
|
|
489
476
|
if (!(key in params) || params[key] == null) {
|
|
490
|
-
if (leaveWildcards) {
|
|
491
|
-
return `${segmentPrefix}${key}${segmentSuffix}`
|
|
492
|
-
}
|
|
493
477
|
// For optional params with prefix/suffix, keep the prefix/suffix but omit the param
|
|
494
478
|
if (segmentPrefix || segmentSuffix) {
|
|
495
479
|
return `${segmentPrefix}${segmentSuffix}`
|
|
@@ -500,13 +484,6 @@ export function interpolatePath({
|
|
|
500
484
|
|
|
501
485
|
usedParams[key] = params[key]
|
|
502
486
|
|
|
503
|
-
if (leaveParams) {
|
|
504
|
-
const value = encodeParam(segment.value)
|
|
505
|
-
return `${segmentPrefix}${segment.value}${value ?? ''}${segmentSuffix}`
|
|
506
|
-
}
|
|
507
|
-
if (leaveWildcards) {
|
|
508
|
-
return `${segmentPrefix}${key}${encodeParam(key) ?? ''}${segmentSuffix}`
|
|
509
|
-
}
|
|
510
487
|
return `${segmentPrefix}${encodeParam(key) ?? ''}${segmentSuffix}`
|
|
511
488
|
}
|
|
512
489
|
|
package/src/router.ts
CHANGED
|
@@ -1364,13 +1364,12 @@ export class RouterCore<
|
|
|
1364
1364
|
// Existing matches are matches that are already loaded along with
|
|
1365
1365
|
// pending matches that are still loading
|
|
1366
1366
|
const matchId =
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
}).interpolatedPath + loaderDepsHash
|
|
1367
|
+
// route.id for disambiguation
|
|
1368
|
+
route.id +
|
|
1369
|
+
// interpolatedPath for param changes
|
|
1370
|
+
interpolatedPath +
|
|
1371
|
+
// explicit deps
|
|
1372
|
+
loaderDepsHash
|
|
1374
1373
|
|
|
1375
1374
|
const existingMatch = this.getMatch(matchId)
|
|
1376
1375
|
|
|
@@ -1684,18 +1683,18 @@ export class RouterCore<
|
|
|
1684
1683
|
}
|
|
1685
1684
|
}
|
|
1686
1685
|
|
|
1687
|
-
const nextPathname =
|
|
1688
|
-
|
|
1689
|
-
// Use the original template path for interpolation
|
|
1686
|
+
const nextPathname = opts.leaveParams
|
|
1687
|
+
? // Use the original template path for interpolation
|
|
1690
1688
|
// This preserves the original parameter syntax including optional parameters
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1689
|
+
nextTo
|
|
1690
|
+
: decodePath(
|
|
1691
|
+
interpolatePath({
|
|
1692
|
+
path: nextTo,
|
|
1693
|
+
params: nextParams,
|
|
1694
|
+
decodeCharMap: this.pathParamsDecodeCharMap,
|
|
1695
|
+
parseCache: this.parsePathnameCache,
|
|
1696
|
+
}).interpolatedPath,
|
|
1697
|
+
)
|
|
1699
1698
|
|
|
1700
1699
|
// Resolve the next search
|
|
1701
1700
|
let nextSearch = fromSearch
|