@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.cjs
CHANGED
|
@@ -236,16 +236,17 @@ class RouterCore {
|
|
|
236
236
|
});
|
|
237
237
|
const lastMatch = utils.last(allFromMatches);
|
|
238
238
|
let fromPath = lastMatch.fullPath;
|
|
239
|
-
const
|
|
239
|
+
const toPath = dest.to ? this.resolvePathWithBase(fromPath, `${dest.to}`) : this.resolvePathWithBase(fromPath, ".");
|
|
240
|
+
const routeIsChanging = !!dest.to && !this.comparePaths(dest.to.toString(), fromPath) && !this.comparePaths(toPath, fromPath);
|
|
240
241
|
if (dest.unsafeRelative === "path") {
|
|
241
242
|
fromPath = currentLocation.pathname;
|
|
242
243
|
} else if (routeIsChanging && dest.from) {
|
|
243
244
|
fromPath = dest.from;
|
|
244
245
|
const existingFrom = [...allFromMatches].reverse().find((d) => {
|
|
245
|
-
return
|
|
246
|
+
return this.comparePaths(d.fullPath, fromPath);
|
|
246
247
|
});
|
|
247
248
|
if (!existingFrom) {
|
|
248
|
-
console.warn(`Could not find match for from: ${
|
|
249
|
+
console.warn(`Could not find match for from: ${fromPath}`);
|
|
249
250
|
}
|
|
250
251
|
}
|
|
251
252
|
const fromSearch = lastMatch.search;
|
|
@@ -1670,6 +1671,9 @@ class RouterCore {
|
|
|
1670
1671
|
});
|
|
1671
1672
|
return matches;
|
|
1672
1673
|
}
|
|
1674
|
+
comparePaths(path1, path2) {
|
|
1675
|
+
return path1.replace(/(.+)\/$/, "$1") === path2.replace(/(.+)\/$/, "$1");
|
|
1676
|
+
}
|
|
1673
1677
|
}
|
|
1674
1678
|
class SearchParamError extends Error {
|
|
1675
1679
|
}
|