@tanstack/router-core 1.145.11 → 1.146.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.
@@ -394,7 +394,7 @@ class RouterCore {
394
394
  this.processedTree
395
395
  );
396
396
  if (match) {
397
- Object.assign(params, match.params);
397
+ Object.assign(params, match.rawParams);
398
398
  const {
399
399
  from: _from,
400
400
  params: maskParams,
@@ -515,7 +515,9 @@ class RouterCore {
515
515
  const parsed = parseHref(href, {
516
516
  __TSR_index: replace ? currentIndex : currentIndex + 1
517
517
  });
518
- rest.to = parsed.pathname;
518
+ const hrefUrl = new URL(parsed.pathname, this.origin);
519
+ const rewrittenUrl = executeRewriteInput(this.rewrite, hrefUrl);
520
+ rest.to = rewrittenUrl.pathname;
519
521
  rest.search = this.options.parseSearch(parsed.search);
520
522
  rest.hash = parsed.hash.slice(1);
521
523
  }
@@ -558,7 +560,7 @@ class RouterCore {
558
560
  reloadDocument = true;
559
561
  }
560
562
  if (reloadDocument) {
561
- if (!href || !publicHref && !hrefIsUrl) {
563
+ if (to !== void 0 || !href) {
562
564
  const location = this.buildLocation({ to, ...rest });
563
565
  href = href ?? location.url.href;
564
566
  publicHref = publicHref ?? location.url.href;
@@ -965,14 +967,14 @@ class RouterCore {
965
967
  return false;
966
968
  }
967
969
  if (location.params) {
968
- if (!deepEqual(match.params, location.params, { partial: true })) {
970
+ if (!deepEqual(match.rawParams, location.params, { partial: true })) {
969
971
  return false;
970
972
  }
971
973
  }
972
974
  if (opts?.includeSearch ?? true) {
973
- return deepEqual(baseLocation.search, next.search, { partial: true }) ? match.params : false;
975
+ return deepEqual(baseLocation.search, next.search, { partial: true }) ? match.rawParams : false;
974
976
  }
975
- return match.params;
977
+ return match.rawParams;
976
978
  };
977
979
  this.hasNotFoundMatch = () => {
978
980
  return this.__store.state.matches.some(
@@ -1008,7 +1010,7 @@ class RouterCore {
1008
1010
  }
1009
1011
  matchRoutesInternal(next, opts) {
1010
1012
  const matchedRoutesResult = this.getMatchedRoutes(next.pathname);
1011
- const { foundRoute, routeParams } = matchedRoutesResult;
1013
+ const { foundRoute, routeParams, parsedParams } = matchedRoutesResult;
1012
1014
  let { matchedRoutes } = matchedRoutesResult;
1013
1015
  let isGlobalNotFound = false;
1014
1016
  if (
@@ -1094,23 +1096,31 @@ class RouterCore {
1094
1096
  const strictParams = existingMatch?._strictParams ?? usedParams;
1095
1097
  let paramsError = void 0;
1096
1098
  if (!existingMatch) {
1097
- const strictParseParams = route.options.params?.parse ?? route.options.parseParams;
1098
- if (strictParseParams) {
1099
- try {
1100
- Object.assign(
1101
- strictParams,
1102
- strictParseParams(strictParams)
1103
- );
1104
- } catch (err) {
1105
- if (isNotFound(err) || isRedirect(err)) {
1106
- paramsError = err;
1107
- } else {
1108
- paramsError = new PathParamError(err.message, {
1109
- cause: err
1110
- });
1099
+ if (route.options.skipRouteOnParseError) {
1100
+ for (const key in usedParams) {
1101
+ if (key in parsedParams) {
1102
+ strictParams[key] = parsedParams[key];
1111
1103
  }
1112
- if (opts?.throwOnError) {
1113
- throw paramsError;
1104
+ }
1105
+ } else {
1106
+ const strictParseParams = route.options.params?.parse ?? route.options.parseParams;
1107
+ if (strictParseParams) {
1108
+ try {
1109
+ Object.assign(
1110
+ strictParams,
1111
+ strictParseParams(strictParams)
1112
+ );
1113
+ } catch (err) {
1114
+ if (isNotFound(err) || isRedirect(err)) {
1115
+ paramsError = err;
1116
+ } else {
1117
+ paramsError = new PathParamError(err.message, {
1118
+ cause: err
1119
+ });
1120
+ }
1121
+ if (opts?.throwOnError) {
1122
+ throw paramsError;
1123
+ }
1114
1124
  }
1115
1125
  }
1116
1126
  }
@@ -1264,13 +1274,15 @@ function getMatchedRoutes({
1264
1274
  const routeParams = {};
1265
1275
  const trimmedPath = trimPathRight(pathname);
1266
1276
  let foundRoute = void 0;
1277
+ let parsedParams = void 0;
1267
1278
  const match = findRouteMatch(trimmedPath, processedTree, true);
1268
1279
  if (match) {
1269
1280
  foundRoute = match.route;
1270
- Object.assign(routeParams, match.params);
1281
+ Object.assign(routeParams, match.rawParams);
1282
+ parsedParams = Object.assign({}, match.parsedParams);
1271
1283
  }
1272
1284
  const matchedRoutes = match?.branch || [routesById[rootRouteId]];
1273
- return { matchedRoutes, routeParams, foundRoute };
1285
+ return { matchedRoutes, routeParams, foundRoute, parsedParams };
1274
1286
  }
1275
1287
  function applySearchMiddleware({
1276
1288
  search,