@tanstack/router-core 1.131.35 → 1.131.37
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 +1 -0
- package/dist/cjs/path.cjs.map +1 -1
- package/dist/cjs/router.cjs +25 -7
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/esm/path.js +1 -0
- package/dist/esm/path.js.map +1 -1
- package/dist/esm/router.js +25 -7
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/path.ts +4 -0
- package/src/router.ts +38 -12
package/src/router.ts
CHANGED
|
@@ -1210,20 +1210,44 @@ export class RouterCore<
|
|
|
1210
1210
|
|
|
1211
1211
|
const loaderDepsHash = loaderDeps ? JSON.stringify(loaderDeps) : ''
|
|
1212
1212
|
|
|
1213
|
-
const {
|
|
1213
|
+
const { interpolatedPath } = interpolatePath({
|
|
1214
1214
|
path: route.fullPath,
|
|
1215
1215
|
params: routeParams,
|
|
1216
1216
|
decodeCharMap: this.pathParamsDecodeCharMap,
|
|
1217
1217
|
})
|
|
1218
1218
|
|
|
1219
|
-
const
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1219
|
+
const interpolatePathResult = interpolatePath({
|
|
1220
|
+
path: route.id,
|
|
1221
|
+
params: routeParams,
|
|
1222
|
+
leaveWildcards: true,
|
|
1223
|
+
decodeCharMap: this.pathParamsDecodeCharMap,
|
|
1224
|
+
parseCache: this.parsePathnameCache,
|
|
1225
|
+
})
|
|
1226
|
+
|
|
1227
|
+
const strictParams = interpolatePathResult.usedParams
|
|
1228
|
+
|
|
1229
|
+
let paramsError = parseErrors[index]
|
|
1230
|
+
|
|
1231
|
+
const strictParseParams =
|
|
1232
|
+
route.options.params?.parse ?? route.options.parseParams
|
|
1233
|
+
|
|
1234
|
+
if (strictParseParams) {
|
|
1235
|
+
try {
|
|
1236
|
+
Object.assign(strictParams, strictParseParams(strictParams as any))
|
|
1237
|
+
} catch (err: any) {
|
|
1238
|
+
// any param errors should already have been dealt with above, if this
|
|
1239
|
+
// somehow differs, let's report this in the same manner
|
|
1240
|
+
if (!paramsError) {
|
|
1241
|
+
paramsError = new PathParamError(err.message, {
|
|
1242
|
+
cause: err,
|
|
1243
|
+
})
|
|
1244
|
+
|
|
1245
|
+
if (opts?.throwOnError) {
|
|
1246
|
+
throw paramsError
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1227
1251
|
|
|
1228
1252
|
// Waste not, want not. If we already have a match for this route,
|
|
1229
1253
|
// reuse it. This is important for layout routes, which might stick
|
|
@@ -1231,6 +1255,8 @@ export class RouterCore<
|
|
|
1231
1255
|
|
|
1232
1256
|
// Existing matches are matches that are already loaded along with
|
|
1233
1257
|
// pending matches that are still loading
|
|
1258
|
+
const matchId = interpolatePathResult.interpolatedPath + loaderDepsHash
|
|
1259
|
+
|
|
1234
1260
|
const existingMatch = this.getMatch(matchId)
|
|
1235
1261
|
|
|
1236
1262
|
const previousMatch = this.state.matches.find(
|
|
@@ -1248,7 +1274,7 @@ export class RouterCore<
|
|
|
1248
1274
|
params: previousMatch
|
|
1249
1275
|
? replaceEqualDeep(previousMatch.params, routeParams)
|
|
1250
1276
|
: routeParams,
|
|
1251
|
-
_strictParams:
|
|
1277
|
+
_strictParams: strictParams,
|
|
1252
1278
|
search: previousMatch
|
|
1253
1279
|
? replaceEqualDeep(previousMatch.search, preMatchSearch)
|
|
1254
1280
|
: replaceEqualDeep(existingMatch.search, preMatchSearch),
|
|
@@ -1270,7 +1296,7 @@ export class RouterCore<
|
|
|
1270
1296
|
params: previousMatch
|
|
1271
1297
|
? replaceEqualDeep(previousMatch.params, routeParams)
|
|
1272
1298
|
: routeParams,
|
|
1273
|
-
_strictParams:
|
|
1299
|
+
_strictParams: strictParams,
|
|
1274
1300
|
pathname: joinPaths([this.basepath, interpolatedPath]),
|
|
1275
1301
|
updatedAt: Date.now(),
|
|
1276
1302
|
search: previousMatch
|
|
@@ -1281,7 +1307,7 @@ export class RouterCore<
|
|
|
1281
1307
|
status,
|
|
1282
1308
|
isFetching: false,
|
|
1283
1309
|
error: undefined,
|
|
1284
|
-
paramsError
|
|
1310
|
+
paramsError,
|
|
1285
1311
|
__routeContext: undefined,
|
|
1286
1312
|
_nonReactive: {
|
|
1287
1313
|
loadPromise: createControlledPromise(),
|