@tanstack/router-core 1.131.27 → 1.131.28
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 +15 -22
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/esm/router.js +15 -22
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/router.ts +31 -36
package/src/router.ts
CHANGED
|
@@ -1414,50 +1414,44 @@ export class RouterCore<
|
|
|
1414
1414
|
_buildLocation: true,
|
|
1415
1415
|
})
|
|
1416
1416
|
|
|
1417
|
+
// Now let's find the starting pathname
|
|
1418
|
+
// This should default to the current location if no from is provided
|
|
1417
1419
|
const lastMatch = last(allCurrentLocationMatches)!
|
|
1418
1420
|
|
|
1419
|
-
//
|
|
1420
|
-
//
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
// If the route is changing we need to find the relative fromPath
|
|
1432
|
-
if (dest.unsafeRelative === 'path') {
|
|
1433
|
-
fromPath = currentLocation.pathname
|
|
1434
|
-
} else if (routeIsChanging && dest.from) {
|
|
1435
|
-
fromPath = dest.from
|
|
1436
|
-
|
|
1437
|
-
// do this check only on navigations during test or development
|
|
1438
|
-
if (process.env.NODE_ENV !== 'production' && dest._isNavigate) {
|
|
1439
|
-
const allFromMatches = this.getMatchedRoutes(
|
|
1440
|
-
dest.from,
|
|
1441
|
-
undefined,
|
|
1442
|
-
).matchedRoutes
|
|
1421
|
+
// check that from path exists in the current route tree
|
|
1422
|
+
// do this check only on navigations during test or development
|
|
1423
|
+
if (
|
|
1424
|
+
dest.from &&
|
|
1425
|
+
process.env.NODE_ENV !== 'production' &&
|
|
1426
|
+
dest._isNavigate
|
|
1427
|
+
) {
|
|
1428
|
+
const allFromMatches = this.getMatchedRoutes(
|
|
1429
|
+
dest.from,
|
|
1430
|
+
undefined,
|
|
1431
|
+
).matchedRoutes
|
|
1443
1432
|
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1433
|
+
const matchedFrom = findLast(allCurrentLocationMatches, (d) => {
|
|
1434
|
+
return comparePaths(d.fullPath, dest.from!)
|
|
1435
|
+
})
|
|
1447
1436
|
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1437
|
+
const matchedCurrent = findLast(allFromMatches, (d) => {
|
|
1438
|
+
return comparePaths(d.fullPath, lastMatch.fullPath)
|
|
1439
|
+
})
|
|
1451
1440
|
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
}
|
|
1441
|
+
// for from to be invalid it shouldn't just be unmatched to currentLocation
|
|
1442
|
+
// but the currentLocation should also be unmatched to from
|
|
1443
|
+
if (!matchedFrom && !matchedCurrent) {
|
|
1444
|
+
console.warn(`Could not find match for from: ${dest.from}`)
|
|
1457
1445
|
}
|
|
1458
1446
|
}
|
|
1459
1447
|
|
|
1460
|
-
|
|
1448
|
+
const defaultedFromPath =
|
|
1449
|
+
dest.unsafeRelative === 'path'
|
|
1450
|
+
? currentLocation.pathname
|
|
1451
|
+
: (dest.from ?? lastMatch.fullPath)
|
|
1452
|
+
|
|
1453
|
+
// ensure this includes the basePath if set
|
|
1454
|
+
const fromPath = this.resolvePathWithBase(defaultedFromPath, '.')
|
|
1461
1455
|
|
|
1462
1456
|
// From search should always use the current location
|
|
1463
1457
|
const fromSearch = lastMatch.search
|
|
@@ -1465,6 +1459,7 @@ export class RouterCore<
|
|
|
1465
1459
|
const fromParams = { ...lastMatch.params }
|
|
1466
1460
|
|
|
1467
1461
|
// Resolve the next to
|
|
1462
|
+
// ensure this includes the basePath if set
|
|
1468
1463
|
const nextTo = dest.to
|
|
1469
1464
|
? this.resolvePathWithBase(fromPath, `${dest.to}`)
|
|
1470
1465
|
: this.resolvePathWithBase(fromPath, '.')
|