@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/package.json
CHANGED
package/src/router.ts
CHANGED
|
@@ -1406,6 +1406,10 @@ export class RouterCore<
|
|
|
1406
1406
|
})
|
|
1407
1407
|
}
|
|
1408
1408
|
|
|
1409
|
+
private comparePaths(path1: string, path2: string) {
|
|
1410
|
+
return path1.replace(/(.+)\/$/, '$1') === path2.replace(/(.+)\/$/, '$1')
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1409
1413
|
buildLocation: BuildLocationFn = (opts) => {
|
|
1410
1414
|
const build = (
|
|
1411
1415
|
dest: BuildNextOptions & {
|
|
@@ -1424,11 +1428,14 @@ export class RouterCore<
|
|
|
1424
1428
|
// First let's find the starting pathname
|
|
1425
1429
|
// By default, start with the current location
|
|
1426
1430
|
let fromPath = lastMatch.fullPath
|
|
1431
|
+
const toPath = dest.to
|
|
1432
|
+
? this.resolvePathWithBase(fromPath, `${dest.to}`)
|
|
1433
|
+
: this.resolvePathWithBase(fromPath, '.')
|
|
1427
1434
|
|
|
1428
1435
|
const routeIsChanging =
|
|
1429
1436
|
!!dest.to &&
|
|
1430
|
-
dest.to
|
|
1431
|
-
this.
|
|
1437
|
+
!this.comparePaths(dest.to.toString(), fromPath) &&
|
|
1438
|
+
!this.comparePaths(toPath, fromPath)
|
|
1432
1439
|
|
|
1433
1440
|
// If the route is changing we need to find the relative fromPath
|
|
1434
1441
|
if (dest.unsafeRelative === 'path') {
|
|
@@ -1436,13 +1443,11 @@ export class RouterCore<
|
|
|
1436
1443
|
} else if (routeIsChanging && dest.from) {
|
|
1437
1444
|
fromPath = dest.from
|
|
1438
1445
|
const existingFrom = [...allFromMatches].reverse().find((d) => {
|
|
1439
|
-
return (
|
|
1440
|
-
d.fullPath === fromPath || d.fullPath === joinPaths([fromPath, '/'])
|
|
1441
|
-
)
|
|
1446
|
+
return this.comparePaths(d.fullPath, fromPath)
|
|
1442
1447
|
})
|
|
1443
1448
|
|
|
1444
1449
|
if (!existingFrom) {
|
|
1445
|
-
console.warn(`Could not find match for from: ${
|
|
1450
|
+
console.warn(`Could not find match for from: ${fromPath}`)
|
|
1446
1451
|
}
|
|
1447
1452
|
}
|
|
1448
1453
|
|