@tanstack/react-router 1.31.16 → 1.31.19
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/RouterProvider.cjs +6 -3
- package/dist/cjs/RouterProvider.cjs.map +1 -1
- package/dist/cjs/router.cjs +6 -3
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/utils.cjs +6 -0
- package/dist/cjs/utils.cjs.map +1 -1
- package/dist/cjs/utils.d.cts +9 -0
- package/dist/esm/RouterProvider.js +6 -3
- package/dist/esm/RouterProvider.js.map +1 -1
- package/dist/esm/router.js +7 -4
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/utils.d.ts +9 -0
- package/dist/esm/utils.js +6 -0
- package/dist/esm/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/RouterProvider.tsx +8 -4
- package/src/router.ts +8 -2
- package/src/utils.ts +14 -0
package/src/router.ts
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
functionalUpdate,
|
|
12
12
|
last,
|
|
13
13
|
pick,
|
|
14
|
+
removeLayoutSegments,
|
|
14
15
|
replaceEqualDeep,
|
|
15
16
|
} from './utils'
|
|
16
17
|
import { getRouteMatch } from './RouterProvider'
|
|
@@ -935,12 +936,17 @@ export class Router<
|
|
|
935
936
|
fromMatches.find((e) => e.routeId === d.routeId),
|
|
936
937
|
)
|
|
937
938
|
|
|
939
|
+
const fromRouteByFromPath = stayingMatches?.find(
|
|
940
|
+
(d) => d.pathname === fromPath,
|
|
941
|
+
)
|
|
942
|
+
|
|
938
943
|
let pathname = dest.to
|
|
939
944
|
? this.resolvePathWithBase(fromPath, `${dest.to}`)
|
|
940
945
|
: this.resolvePathWithBase(
|
|
941
946
|
fromPath,
|
|
942
|
-
|
|
943
|
-
|
|
947
|
+
fromRouteByFromPath
|
|
948
|
+
? removeLayoutSegments(fromRouteByFromPath.routeId)
|
|
949
|
+
: fromPath,
|
|
944
950
|
)
|
|
945
951
|
|
|
946
952
|
const prevParams = { ...last(fromMatches)?.params }
|
package/src/utils.ts
CHANGED
|
@@ -339,3 +339,17 @@ export function createControlledPromise<T>(onResolve?: () => void) {
|
|
|
339
339
|
|
|
340
340
|
return controlledPromise
|
|
341
341
|
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Removes all segments from a given path that start with an underscore ('_').
|
|
345
|
+
*
|
|
346
|
+
* @param {string} routePath - The path from which to remove segments. Defaults to '/'.
|
|
347
|
+
* @returns {string} The path with all underscore-prefixed segments removed.
|
|
348
|
+
* @example
|
|
349
|
+
* removeLayoutSegments('/workspace/_auth/foo') // '/workspace/foo'
|
|
350
|
+
*/
|
|
351
|
+
export function removeLayoutSegments(routePath: string): string {
|
|
352
|
+
const segments = routePath.split('/')
|
|
353
|
+
const newSegments = segments.filter((segment) => !segment.startsWith('_'))
|
|
354
|
+
return newSegments.join('/')
|
|
355
|
+
}
|