@tanstack/router-core 1.129.3 → 1.129.5

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.129.3",
3
+ "version": "1.129.5",
4
4
  "description": "Modern and scalable routing for React applications",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -30,7 +30,7 @@ export type NavigateFn = <
30
30
  TMaskTo extends string = '',
31
31
  >(
32
32
  opts: NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,
33
- ) => Promise<void> | void
33
+ ) => Promise<void>
34
34
 
35
35
  export type BuildLocationFn = <
36
36
  TRouter extends RegisteredRouter,
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(/\/$/, '') === path2.replace(/\/$/, '')
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
- !this.comparePaths(dest.to.toString(), fromPath) &&
1401
- !this.comparePaths(toPath, fromPath)
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 this.comparePaths(d.fullPath, fromPath)
1415
+ return comparePaths(d.fullPath, fromPath)
1420
1416
  })
1421
1417
 
1422
1418
  const matchedCurrent = [...allFromMatches].reverse().find((d) => {
1423
- return this.comparePaths(d.fullPath, currentLocation.pathname)
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
@@ -1759,7 +1755,7 @@ export class RouterCore<
1759
1755
  } else {
1760
1756
  window.location.href = href
1761
1757
  }
1762
- return
1758
+ return Promise.resolve()
1763
1759
  }
1764
1760
 
1765
1761
  return this.buildAndCommitLocation({
@@ -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