@tanstack/router-core 1.125.4 → 1.126.2

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.
@@ -23,4 +23,5 @@ export type NavigateFn = <TRouter extends RegisteredRouter, TTo extends string |
23
23
  export type BuildLocationFn = <TRouter extends RegisteredRouter, TTo extends string | undefined, TFrom extends RoutePaths<TRouter['routeTree']> | string = string, TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom, TMaskTo extends string = ''>(opts: ToOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & {
24
24
  leaveParams?: boolean;
25
25
  _includeValidateSearch?: boolean;
26
+ _isNavigate?: boolean;
26
27
  }) => ParsedLocation;
@@ -231,10 +231,10 @@ class RouterCore {
231
231
  const build = (dest = {}) => {
232
232
  var _a;
233
233
  const currentLocation = dest._fromLocation || this.latestLocation;
234
- const allFromMatches = this.matchRoutes(currentLocation, {
234
+ const allCurrentLocationMatches = this.matchRoutes(currentLocation, {
235
235
  _buildLocation: true
236
236
  });
237
- const lastMatch = utils.last(allFromMatches);
237
+ const lastMatch = utils.last(allCurrentLocationMatches);
238
238
  let fromPath = lastMatch.fullPath;
239
239
  const toPath = dest.to ? this.resolvePathWithBase(fromPath, `${dest.to}`) : this.resolvePathWithBase(fromPath, ".");
240
240
  const routeIsChanging = !!dest.to && !this.comparePaths(dest.to.toString(), fromPath) && !this.comparePaths(toPath, fromPath);
@@ -242,11 +242,20 @@ class RouterCore {
242
242
  fromPath = currentLocation.pathname;
243
243
  } else if (routeIsChanging && dest.from) {
244
244
  fromPath = dest.from;
245
- const existingFrom = [...allFromMatches].reverse().find((d) => {
246
- return this.comparePaths(d.fullPath, fromPath);
247
- });
248
- if (!existingFrom) {
249
- console.warn(`Could not find match for from: ${fromPath}`);
245
+ if (process.env.NODE_ENV !== "production" && dest._isNavigate) {
246
+ const allFromMatches = this.getMatchedRoutes(
247
+ dest.from,
248
+ void 0
249
+ ).matchedRoutes;
250
+ const matchedFrom = [...allCurrentLocationMatches].reverse().find((d) => {
251
+ return this.comparePaths(d.fullPath, fromPath);
252
+ });
253
+ const matchedCurrent = [...allFromMatches].reverse().find((d) => {
254
+ return this.comparePaths(d.fullPath, currentLocation.pathname);
255
+ });
256
+ if (!matchedFrom && !matchedCurrent) {
257
+ console.warn(`Could not find match for from: ${fromPath}`);
258
+ }
250
259
  }
251
260
  }
252
261
  const fromSearch = lastMatch.search;
@@ -484,7 +493,8 @@ class RouterCore {
484
493
  return this.buildAndCommitLocation({
485
494
  ...rest,
486
495
  href,
487
- to
496
+ to,
497
+ _isNavigate: true
488
498
  });
489
499
  };
490
500
  this.beforeLoad = () => {