@tanstack/router-core 1.125.3 → 1.125.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.
@@ -537,6 +537,7 @@ export declare class RouterCore<in out TRouteTree extends AnyRoute, in out TTrai
537
537
  getMatchedRoutes: GetMatchRoutesFn;
538
538
  cancelMatch: (id: string) => void;
539
539
  cancelMatches: () => void;
540
+ private comparePaths;
540
541
  buildLocation: BuildLocationFn;
541
542
  commitLocationPromise: undefined | ControlledPromise<void>;
542
543
  commitLocation: CommitLocationFn;
@@ -537,6 +537,7 @@ export declare class RouterCore<in out TRouteTree extends AnyRoute, in out TTrai
537
537
  getMatchedRoutes: GetMatchRoutesFn;
538
538
  cancelMatch: (id: string) => void;
539
539
  cancelMatches: () => void;
540
+ private comparePaths;
540
541
  buildLocation: BuildLocationFn;
541
542
  commitLocationPromise: undefined | ControlledPromise<void>;
542
543
  commitLocation: CommitLocationFn;
@@ -234,16 +234,17 @@ class RouterCore {
234
234
  });
235
235
  const lastMatch = last(allFromMatches);
236
236
  let fromPath = lastMatch.fullPath;
237
- const routeIsChanging = !!dest.to && dest.to !== fromPath && this.resolvePathWithBase(fromPath, `${dest.to}`) !== fromPath;
237
+ const toPath = dest.to ? this.resolvePathWithBase(fromPath, `${dest.to}`) : this.resolvePathWithBase(fromPath, ".");
238
+ const routeIsChanging = !!dest.to && !this.comparePaths(dest.to.toString(), fromPath) && !this.comparePaths(toPath, fromPath);
238
239
  if (dest.unsafeRelative === "path") {
239
240
  fromPath = currentLocation.pathname;
240
241
  } else if (routeIsChanging && dest.from) {
241
242
  fromPath = dest.from;
242
243
  const existingFrom = [...allFromMatches].reverse().find((d) => {
243
- return d.fullPath === fromPath || d.fullPath === joinPaths([fromPath, "/"]);
244
+ return this.comparePaths(d.fullPath, fromPath);
244
245
  });
245
246
  if (!existingFrom) {
246
- console.warn(`Could not find match for from: ${dest.from}`);
247
+ console.warn(`Could not find match for from: ${fromPath}`);
247
248
  }
248
249
  }
249
250
  const fromSearch = lastMatch.search;
@@ -1668,6 +1669,9 @@ class RouterCore {
1668
1669
  });
1669
1670
  return matches;
1670
1671
  }
1672
+ comparePaths(path1, path2) {
1673
+ return path1.replace(/(.+)\/$/, "$1") === path2.replace(/(.+)\/$/, "$1");
1674
+ }
1671
1675
  }
1672
1676
  class SearchParamError extends Error {
1673
1677
  }