@tanstack/router-core 1.124.0 → 1.124.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/router-core",
3
- "version": "1.124.0",
3
+ "version": "1.124.2",
4
4
  "description": "Modern and scalable routing for React applications",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
package/src/router.ts CHANGED
@@ -1415,11 +1415,15 @@ export class RouterCore<
1415
1415
  // By default, start with the current location
1416
1416
  let fromPath = lastMatch.fullPath
1417
1417
 
1418
- // If there is a to, it means we are changing the path in some way
1419
- // So we need to find the relative fromPath
1418
+ const routeIsChanging =
1419
+ !!dest.to &&
1420
+ dest.to !== fromPath &&
1421
+ this.resolvePathWithBase(fromPath, `${dest.to}`) !== fromPath
1422
+
1423
+ // If the route is changing we need to find the relative fromPath
1420
1424
  if (dest.unsafeRelative === 'path') {
1421
1425
  fromPath = currentLocation.pathname
1422
- } else if (dest.to && dest.from) {
1426
+ } else if (routeIsChanging && dest.from) {
1423
1427
  fromPath = dest.from
1424
1428
  const existingFrom = [...allFromMatches].reverse().find((d) => {
1425
1429
  return (
@@ -1708,6 +1712,7 @@ export class RouterCore<
1708
1712
  }: BuildNextOptions & CommitLocationOptions = {}) => {
1709
1713
  if (href) {
1710
1714
  const currentIndex = this.history.location.state.__TSR_index
1715
+
1711
1716
  const parsed = parseHref(href, {
1712
1717
  __TSR_index: replace ? currentIndex : currentIndex + 1,
1713
1718
  })
@@ -1721,6 +1726,7 @@ export class RouterCore<
1721
1726
  ...(rest as any),
1722
1727
  _includeValidateSearch: true,
1723
1728
  })
1729
+
1724
1730
  return this.commitLocation({
1725
1731
  ...location,
1726
1732
  viewTransition,