@tanstack/router-core 1.129.2 → 1.129.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 -6
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +0 -1
- package/dist/esm/router.d.ts +0 -1
- package/dist/esm/router.js +7 -6
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/router.ts +10 -8
package/package.json
CHANGED
package/src/router.ts
CHANGED
|
@@ -1369,10 +1369,6 @@ export class RouterCore<
|
|
|
1369
1369
|
})
|
|
1370
1370
|
}
|
|
1371
1371
|
|
|
1372
|
-
private comparePaths(path1: string, path2: string) {
|
|
1373
|
-
return path1.replace(/(.+)\/$/, '$1') === path2.replace(/(.+)\/$/, '$1')
|
|
1374
|
-
}
|
|
1375
|
-
|
|
1376
1372
|
buildLocation: BuildLocationFn = (opts) => {
|
|
1377
1373
|
const build = (
|
|
1378
1374
|
dest: BuildNextOptions & {
|
|
@@ -1397,8 +1393,8 @@ export class RouterCore<
|
|
|
1397
1393
|
|
|
1398
1394
|
const routeIsChanging =
|
|
1399
1395
|
!!dest.to &&
|
|
1400
|
-
!
|
|
1401
|
-
!
|
|
1396
|
+
!comparePaths(dest.to.toString(), fromPath) &&
|
|
1397
|
+
!comparePaths(toPath, fromPath)
|
|
1402
1398
|
|
|
1403
1399
|
// If the route is changing we need to find the relative fromPath
|
|
1404
1400
|
if (dest.unsafeRelative === 'path') {
|
|
@@ -1416,11 +1412,11 @@ export class RouterCore<
|
|
|
1416
1412
|
const matchedFrom = [...allCurrentLocationMatches]
|
|
1417
1413
|
.reverse()
|
|
1418
1414
|
.find((d) => {
|
|
1419
|
-
return
|
|
1415
|
+
return comparePaths(d.fullPath, fromPath)
|
|
1420
1416
|
})
|
|
1421
1417
|
|
|
1422
1418
|
const matchedCurrent = [...allFromMatches].reverse().find((d) => {
|
|
1423
|
-
return
|
|
1419
|
+
return comparePaths(d.fullPath, currentLocation.pathname)
|
|
1424
1420
|
})
|
|
1425
1421
|
|
|
1426
1422
|
// for from to be invalid it shouldn't just be unmatched to currentLocation
|
|
@@ -3077,6 +3073,12 @@ export class SearchParamError extends Error {}
|
|
|
3077
3073
|
|
|
3078
3074
|
export class PathParamError extends Error {}
|
|
3079
3075
|
|
|
3076
|
+
const normalize = (str: string) =>
|
|
3077
|
+
str.endsWith('/') && str.length > 1 ? str.slice(0, -1) : str
|
|
3078
|
+
function comparePaths(a: string, b: string) {
|
|
3079
|
+
return normalize(a) === normalize(b)
|
|
3080
|
+
}
|
|
3081
|
+
|
|
3080
3082
|
// A function that takes an import() argument which is a function and returns a new function that will
|
|
3081
3083
|
// proxy arguments from the caller to the imported function, retaining all type
|
|
3082
3084
|
// information along the way
|