@tanstack/router-core 1.132.0-alpha.20 → 1.132.0-alpha.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/dist/cjs/path.cjs +8 -7
- package/dist/cjs/path.cjs.map +1 -1
- package/dist/cjs/router.cjs +4 -5
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/esm/path.js +8 -7
- package/dist/esm/path.js.map +1 -1
- package/dist/esm/router.js +4 -5
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/path.ts +12 -9
- package/src/router.ts +10 -12
package/package.json
CHANGED
package/src/path.ts
CHANGED
|
@@ -259,8 +259,11 @@ function baseParsePathname(pathname: string): ReadonlyArray<Segment> {
|
|
|
259
259
|
|
|
260
260
|
segments.push(
|
|
261
261
|
...split.map((part): Segment => {
|
|
262
|
+
// strip tailing underscore for non-nested paths
|
|
263
|
+
const partToMatch = part.slice(-1) === '_' ? part.slice(0, -1) : part
|
|
264
|
+
|
|
262
265
|
// Check for wildcard with curly braces: prefix{$}suffix
|
|
263
|
-
const wildcardBracesMatch =
|
|
266
|
+
const wildcardBracesMatch = partToMatch.match(WILDCARD_W_CURLY_BRACES_RE)
|
|
264
267
|
if (wildcardBracesMatch) {
|
|
265
268
|
const prefix = wildcardBracesMatch[1]
|
|
266
269
|
const suffix = wildcardBracesMatch[2]
|
|
@@ -273,7 +276,7 @@ function baseParsePathname(pathname: string): ReadonlyArray<Segment> {
|
|
|
273
276
|
}
|
|
274
277
|
|
|
275
278
|
// Check for optional parameter format: prefix{-$paramName}suffix
|
|
276
|
-
const optionalParamBracesMatch =
|
|
279
|
+
const optionalParamBracesMatch = partToMatch.match(
|
|
277
280
|
OPTIONAL_PARAM_W_CURLY_BRACES_RE,
|
|
278
281
|
)
|
|
279
282
|
if (optionalParamBracesMatch) {
|
|
@@ -289,7 +292,7 @@ function baseParsePathname(pathname: string): ReadonlyArray<Segment> {
|
|
|
289
292
|
}
|
|
290
293
|
|
|
291
294
|
// Check for the new parameter format: prefix{$paramName}suffix
|
|
292
|
-
const paramBracesMatch =
|
|
295
|
+
const paramBracesMatch = partToMatch.match(PARAM_W_CURLY_BRACES_RE)
|
|
293
296
|
if (paramBracesMatch) {
|
|
294
297
|
const prefix = paramBracesMatch[1]
|
|
295
298
|
const paramName = paramBracesMatch[2]
|
|
@@ -303,8 +306,8 @@ function baseParsePathname(pathname: string): ReadonlyArray<Segment> {
|
|
|
303
306
|
}
|
|
304
307
|
|
|
305
308
|
// Check for bare parameter format: $paramName (without curly braces)
|
|
306
|
-
if (PARAM_RE.test(
|
|
307
|
-
const paramName =
|
|
309
|
+
if (PARAM_RE.test(partToMatch)) {
|
|
310
|
+
const paramName = partToMatch.substring(1)
|
|
308
311
|
return {
|
|
309
312
|
type: SEGMENT_TYPE_PARAM,
|
|
310
313
|
value: '$' + paramName,
|
|
@@ -314,7 +317,7 @@ function baseParsePathname(pathname: string): ReadonlyArray<Segment> {
|
|
|
314
317
|
}
|
|
315
318
|
|
|
316
319
|
// Check for bare wildcard: $ (without curly braces)
|
|
317
|
-
if (WILDCARD_RE.test(
|
|
320
|
+
if (WILDCARD_RE.test(partToMatch)) {
|
|
318
321
|
return {
|
|
319
322
|
type: SEGMENT_TYPE_WILDCARD,
|
|
320
323
|
value: '$',
|
|
@@ -326,12 +329,12 @@ function baseParsePathname(pathname: string): ReadonlyArray<Segment> {
|
|
|
326
329
|
// Handle regular pathname segment
|
|
327
330
|
return {
|
|
328
331
|
type: SEGMENT_TYPE_PATHNAME,
|
|
329
|
-
value:
|
|
330
|
-
?
|
|
332
|
+
value: partToMatch.includes('%25')
|
|
333
|
+
? partToMatch
|
|
331
334
|
.split('%25')
|
|
332
335
|
.map((segment) => decodeURI(segment))
|
|
333
336
|
.join('%25')
|
|
334
|
-
: decodeURI(
|
|
337
|
+
: decodeURI(partToMatch),
|
|
335
338
|
}
|
|
336
339
|
}),
|
|
337
340
|
)
|
package/src/router.ts
CHANGED
|
@@ -1274,27 +1274,26 @@ export class RouterCore<
|
|
|
1274
1274
|
|
|
1275
1275
|
const loaderDepsHash = loaderDeps ? JSON.stringify(loaderDeps) : ''
|
|
1276
1276
|
|
|
1277
|
-
const { interpolatedPath } = interpolatePath({
|
|
1277
|
+
const { interpolatedPath, usedParams } = interpolatePath({
|
|
1278
1278
|
path: route.fullPath,
|
|
1279
1279
|
params: routeParams,
|
|
1280
1280
|
decodeCharMap: this.pathParamsDecodeCharMap,
|
|
1281
1281
|
})
|
|
1282
1282
|
|
|
1283
|
-
const interpolatePathResult = interpolatePath({
|
|
1284
|
-
path: route.id,
|
|
1285
|
-
params: routeParams,
|
|
1286
|
-
leaveWildcards: true,
|
|
1287
|
-
decodeCharMap: this.pathParamsDecodeCharMap,
|
|
1288
|
-
parseCache: this.parsePathnameCache,
|
|
1289
|
-
})
|
|
1290
|
-
|
|
1291
1283
|
// Waste not, want not. If we already have a match for this route,
|
|
1292
1284
|
// reuse it. This is important for layout routes, which might stick
|
|
1293
1285
|
// around between navigation actions that only change leaf routes.
|
|
1294
1286
|
|
|
1295
1287
|
// Existing matches are matches that are already loaded along with
|
|
1296
1288
|
// pending matches that are still loading
|
|
1297
|
-
const matchId =
|
|
1289
|
+
const matchId =
|
|
1290
|
+
interpolatePath({
|
|
1291
|
+
path: route.id,
|
|
1292
|
+
params: routeParams,
|
|
1293
|
+
leaveWildcards: true,
|
|
1294
|
+
decodeCharMap: this.pathParamsDecodeCharMap,
|
|
1295
|
+
parseCache: this.parsePathnameCache,
|
|
1296
|
+
}).interpolatedPath + loaderDepsHash
|
|
1298
1297
|
|
|
1299
1298
|
const existingMatch = this.getMatch(matchId)
|
|
1300
1299
|
|
|
@@ -1302,8 +1301,7 @@ export class RouterCore<
|
|
|
1302
1301
|
(d) => d.routeId === route.id,
|
|
1303
1302
|
)
|
|
1304
1303
|
|
|
1305
|
-
const strictParams =
|
|
1306
|
-
existingMatch?._strictParams ?? interpolatePathResult.usedParams
|
|
1304
|
+
const strictParams = existingMatch?._strictParams ?? usedParams
|
|
1307
1305
|
|
|
1308
1306
|
let paramsError: PathParamError | undefined = undefined
|
|
1309
1307
|
|