@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.
- package/dist/cjs/router.cjs +7 -3
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +1 -0
- package/dist/esm/router.d.ts +1 -0
- package/dist/esm/router.js +7 -3
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/router.ts +11 -6
package/dist/cjs/router.d.cts
CHANGED
|
@@ -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;
|
package/dist/esm/router.d.ts
CHANGED
|
@@ -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;
|
package/dist/esm/router.js
CHANGED
|
@@ -234,16 +234,17 @@ class RouterCore {
|
|
|
234
234
|
});
|
|
235
235
|
const lastMatch = last(allFromMatches);
|
|
236
236
|
let fromPath = lastMatch.fullPath;
|
|
237
|
-
const
|
|
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
|
|
244
|
+
return this.comparePaths(d.fullPath, fromPath);
|
|
244
245
|
});
|
|
245
246
|
if (!existingFrom) {
|
|
246
|
-
console.warn(`Could not find match for 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
|
}
|