@tanstack/router-core 1.129.3 → 1.129.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 -6
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +0 -1
- package/dist/esm/router.d.ts +0 -1
- package/dist/esm/router.js +7 -6
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/router.ts +10 -8
package/dist/cjs/router.d.cts
CHANGED
|
@@ -499,7 +499,6 @@ export declare class RouterCore<in out TRouteTree extends AnyRoute, in out TTrai
|
|
|
499
499
|
getMatchedRoutes: GetMatchRoutesFn;
|
|
500
500
|
cancelMatch: (id: string) => void;
|
|
501
501
|
cancelMatches: () => void;
|
|
502
|
-
private comparePaths;
|
|
503
502
|
buildLocation: BuildLocationFn;
|
|
504
503
|
commitLocationPromise: undefined | ControlledPromise<void>;
|
|
505
504
|
commitLocation: CommitLocationFn;
|
package/dist/esm/router.d.ts
CHANGED
|
@@ -499,7 +499,6 @@ export declare class RouterCore<in out TRouteTree extends AnyRoute, in out TTrai
|
|
|
499
499
|
getMatchedRoutes: GetMatchRoutesFn;
|
|
500
500
|
cancelMatch: (id: string) => void;
|
|
501
501
|
cancelMatches: () => void;
|
|
502
|
-
private comparePaths;
|
|
503
502
|
buildLocation: BuildLocationFn;
|
|
504
503
|
commitLocationPromise: undefined | ControlledPromise<void>;
|
|
505
504
|
commitLocation: CommitLocationFn;
|
package/dist/esm/router.js
CHANGED
|
@@ -231,7 +231,7 @@ class RouterCore {
|
|
|
231
231
|
const lastMatch = last(allCurrentLocationMatches);
|
|
232
232
|
let fromPath = lastMatch.fullPath;
|
|
233
233
|
const toPath = dest.to ? this.resolvePathWithBase(fromPath, `${dest.to}`) : this.resolvePathWithBase(fromPath, ".");
|
|
234
|
-
const routeIsChanging = !!dest.to && !
|
|
234
|
+
const routeIsChanging = !!dest.to && !comparePaths(dest.to.toString(), fromPath) && !comparePaths(toPath, fromPath);
|
|
235
235
|
if (dest.unsafeRelative === "path") {
|
|
236
236
|
fromPath = currentLocation.pathname;
|
|
237
237
|
} else if (routeIsChanging && dest.from) {
|
|
@@ -242,10 +242,10 @@ class RouterCore {
|
|
|
242
242
|
void 0
|
|
243
243
|
).matchedRoutes;
|
|
244
244
|
const matchedFrom = [...allCurrentLocationMatches].reverse().find((d) => {
|
|
245
|
-
return
|
|
245
|
+
return comparePaths(d.fullPath, fromPath);
|
|
246
246
|
});
|
|
247
247
|
const matchedCurrent = [...allFromMatches].reverse().find((d) => {
|
|
248
|
-
return
|
|
248
|
+
return comparePaths(d.fullPath, currentLocation.pathname);
|
|
249
249
|
});
|
|
250
250
|
if (!matchedFrom && !matchedCurrent) {
|
|
251
251
|
console.warn(`Could not find match for from: ${fromPath}`);
|
|
@@ -1644,14 +1644,15 @@ class RouterCore {
|
|
|
1644
1644
|
});
|
|
1645
1645
|
return matches;
|
|
1646
1646
|
}
|
|
1647
|
-
comparePaths(path1, path2) {
|
|
1648
|
-
return path1.replace(/\/$/, "") === path2.replace(/\/$/, "");
|
|
1649
|
-
}
|
|
1650
1647
|
}
|
|
1651
1648
|
class SearchParamError extends Error {
|
|
1652
1649
|
}
|
|
1653
1650
|
class PathParamError extends Error {
|
|
1654
1651
|
}
|
|
1652
|
+
const normalize = (str) => str.endsWith("/") && str.length > 1 ? str.slice(0, -1) : str;
|
|
1653
|
+
function comparePaths(a, b) {
|
|
1654
|
+
return normalize(a) === normalize(b);
|
|
1655
|
+
}
|
|
1655
1656
|
function lazyFn(fn, key) {
|
|
1656
1657
|
return async (...args) => {
|
|
1657
1658
|
const imported = await fn();
|