@tanstack/router-core 1.129.3 → 1.129.5
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/RouterProvider.d.cts +1 -1
- package/dist/cjs/router.cjs +8 -7
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +0 -1
- package/dist/esm/RouterProvider.d.ts +1 -1
- package/dist/esm/router.d.ts +0 -1
- package/dist/esm/router.js +8 -7
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/RouterProvider.ts +1 -1
- package/src/router.ts +11 -9
|
@@ -19,7 +19,7 @@ export interface CommitLocationOptions {
|
|
|
19
19
|
startTransition?: boolean;
|
|
20
20
|
ignoreBlocker?: boolean;
|
|
21
21
|
}
|
|
22
|
-
export type NavigateFn = <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: NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>) => Promise<void
|
|
22
|
+
export type NavigateFn = <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: NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>) => Promise<void>;
|
|
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;
|
package/dist/cjs/router.cjs
CHANGED
|
@@ -233,7 +233,7 @@ class RouterCore {
|
|
|
233
233
|
const lastMatch = utils.last(allCurrentLocationMatches);
|
|
234
234
|
let fromPath = lastMatch.fullPath;
|
|
235
235
|
const toPath = dest.to ? this.resolvePathWithBase(fromPath, `${dest.to}`) : this.resolvePathWithBase(fromPath, ".");
|
|
236
|
-
const routeIsChanging = !!dest.to && !
|
|
236
|
+
const routeIsChanging = !!dest.to && !comparePaths(dest.to.toString(), fromPath) && !comparePaths(toPath, fromPath);
|
|
237
237
|
if (dest.unsafeRelative === "path") {
|
|
238
238
|
fromPath = currentLocation.pathname;
|
|
239
239
|
} else if (routeIsChanging && dest.from) {
|
|
@@ -244,10 +244,10 @@ class RouterCore {
|
|
|
244
244
|
void 0
|
|
245
245
|
).matchedRoutes;
|
|
246
246
|
const matchedFrom = [...allCurrentLocationMatches].reverse().find((d) => {
|
|
247
|
-
return
|
|
247
|
+
return comparePaths(d.fullPath, fromPath);
|
|
248
248
|
});
|
|
249
249
|
const matchedCurrent = [...allFromMatches].reverse().find((d) => {
|
|
250
|
-
return
|
|
250
|
+
return comparePaths(d.fullPath, currentLocation.pathname);
|
|
251
251
|
});
|
|
252
252
|
if (!matchedFrom && !matchedCurrent) {
|
|
253
253
|
console.warn(`Could not find match for from: ${fromPath}`);
|
|
@@ -490,7 +490,7 @@ class RouterCore {
|
|
|
490
490
|
} else {
|
|
491
491
|
window.location.href = href;
|
|
492
492
|
}
|
|
493
|
-
return;
|
|
493
|
+
return Promise.resolve();
|
|
494
494
|
}
|
|
495
495
|
return this.buildAndCommitLocation({
|
|
496
496
|
...rest,
|
|
@@ -1646,14 +1646,15 @@ class RouterCore {
|
|
|
1646
1646
|
});
|
|
1647
1647
|
return matches;
|
|
1648
1648
|
}
|
|
1649
|
-
comparePaths(path1, path2) {
|
|
1650
|
-
return path1.replace(/\/$/, "") === path2.replace(/\/$/, "");
|
|
1651
|
-
}
|
|
1652
1649
|
}
|
|
1653
1650
|
class SearchParamError extends Error {
|
|
1654
1651
|
}
|
|
1655
1652
|
class PathParamError extends Error {
|
|
1656
1653
|
}
|
|
1654
|
+
const normalize = (str) => str.endsWith("/") && str.length > 1 ? str.slice(0, -1) : str;
|
|
1655
|
+
function comparePaths(a, b) {
|
|
1656
|
+
return normalize(a) === normalize(b);
|
|
1657
|
+
}
|
|
1657
1658
|
function lazyFn(fn, key) {
|
|
1658
1659
|
return async (...args) => {
|
|
1659
1660
|
const imported = await fn();
|