@tanstack/router-core 1.158.1 → 1.159.4

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.
@@ -234,14 +234,14 @@ class RouterCore {
234
234
  return {
235
235
  href: pathname + searchStr2 + hash,
236
236
  publicHref: href,
237
- pathname: utils.decodePath(pathname),
237
+ pathname: utils.decodePath(pathname).path,
238
238
  external: false,
239
239
  searchStr: searchStr2,
240
240
  search: utils.replaceEqualDeep(
241
241
  previousLocation?.search,
242
242
  parsedSearch2
243
243
  ),
244
- hash: utils.decodePath(hash.slice(1)),
244
+ hash: utils.decodePath(hash.slice(1)).path,
245
245
  state: utils.replaceEqualDeep(previousLocation?.state, state)
246
246
  };
247
247
  }
@@ -254,11 +254,11 @@ class RouterCore {
254
254
  return {
255
255
  href: fullPath,
256
256
  publicHref: href,
257
- pathname: utils.decodePath(url.pathname),
257
+ pathname: utils.decodePath(url.pathname).path,
258
258
  external: !!this.rewrite && url.origin !== this.origin,
259
259
  searchStr,
260
260
  search: utils.replaceEqualDeep(previousLocation?.search, parsedSearch),
261
- hash: utils.decodePath(url.hash.slice(1)),
261
+ hash: utils.decodePath(url.hash.slice(1)).path,
262
262
  state: utils.replaceEqualDeep(previousLocation?.state, state)
263
263
  };
264
264
  };
@@ -385,7 +385,7 @@ class RouterCore {
385
385
  decoder: this.pathParamsDecoder,
386
386
  server: this.isServer
387
387
  }).interpolatedPath
388
- );
388
+ ).path;
389
389
  let nextSearch = fromSearch;
390
390
  if (opts._includeValidateSearch && this.options.search?.strict) {
391
391
  const validatedSearch = {};
@@ -1129,6 +1129,9 @@ class RouterCore {
1129
1129
  }
1130
1130
  const globalNotFoundRouteId = isGlobalNotFound ? findGlobalNotFoundRouteId(this.options.notFoundMode, matchedRoutes) : void 0;
1131
1131
  const matches = new Array(matchedRoutes.length);
1132
+ const previousMatchesByRouteId = new Map(
1133
+ this.state.matches.map((match) => [match.routeId, match])
1134
+ );
1132
1135
  for (let index = 0; index < matchedRoutes.length; index++) {
1133
1136
  const route = matchedRoutes[index];
1134
1137
  const parentMatch = matches[index - 1];
@@ -1178,9 +1181,7 @@ class RouterCore {
1178
1181
  loaderDepsHash
1179
1182
  );
1180
1183
  const existingMatch = this.getMatch(matchId);
1181
- const previousMatch = this.state.matches.find(
1182
- (d) => d.routeId === route.id
1183
- );
1184
+ const previousMatch = previousMatchesByRouteId.get(route.id);
1184
1185
  const strictParams = existingMatch?._strictParams ?? usedParams;
1185
1186
  let paramsError = void 0;
1186
1187
  if (!existingMatch) {
@@ -1206,7 +1207,7 @@ class RouterCore {
1206
1207
  match = {
1207
1208
  ...existingMatch,
1208
1209
  cause,
1209
- params: previousMatch ? utils.replaceEqualDeep(previousMatch.params, routeParams) : routeParams,
1210
+ params: previousMatch?.params ?? routeParams,
1210
1211
  _strictParams: strictParams,
1211
1212
  search: previousMatch ? utils.replaceEqualDeep(previousMatch.search, preMatchSearch) : utils.replaceEqualDeep(existingMatch.search, preMatchSearch),
1212
1213
  _strictSearch: strictMatchSearch
@@ -1218,7 +1219,7 @@ class RouterCore {
1218
1219
  ssr: isServer.isServer ?? this.isServer ? void 0 : route.options.ssr,
1219
1220
  index,
1220
1221
  routeId: route.id,
1221
- params: previousMatch ? utils.replaceEqualDeep(previousMatch.params, routeParams) : routeParams,
1222
+ params: previousMatch?.params ?? routeParams,
1222
1223
  _strictParams: strictParams,
1223
1224
  pathname: interpolatedPath,
1224
1225
  updatedAt: Date.now(),
@@ -1265,6 +1266,8 @@ class RouterCore {
1265
1266
  const match = matches[index];
1266
1267
  const route = this.looseRoutesById[match.routeId];
1267
1268
  const existingMatch = this.getMatch(match.id);
1269
+ const previousMatch = previousMatchesByRouteId.get(match.routeId);
1270
+ match.params = previousMatch ? utils.replaceEqualDeep(previousMatch.params, routeParams) : routeParams;
1268
1271
  if (!existingMatch) {
1269
1272
  const parentMatch = matches[index - 1];
1270
1273
  const parentContext = this.getParentContext(parentMatch);