@tanstack/router-core 1.139.0 → 1.139.3
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/new-process-route-tree.cjs +2 -2
- package/dist/cjs/new-process-route-tree.cjs.map +1 -1
- package/dist/cjs/path.cjs +3 -8
- package/dist/cjs/path.cjs.map +1 -1
- package/dist/cjs/router.cjs +18 -1
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/esm/new-process-route-tree.js +2 -2
- package/dist/esm/new-process-route-tree.js.map +1 -1
- package/dist/esm/path.js +3 -8
- package/dist/esm/path.js.map +1 -1
- package/dist/esm/router.js +18 -1
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/new-process-route-tree.ts +7 -2
- package/src/path.ts +3 -10
- package/src/router.ts +21 -1
|
@@ -878,7 +878,7 @@ function getNodeMatch<T extends RouteLike>(
|
|
|
878
878
|
}
|
|
879
879
|
|
|
880
880
|
// perfect match, no need to continue
|
|
881
|
-
if (statics === partsLength) return bestMatch
|
|
881
|
+
if (statics === partsLength && node.isIndex) return bestMatch
|
|
882
882
|
}
|
|
883
883
|
// beyond the length of the path parts, only skipped optional segments or wildcard segments can match
|
|
884
884
|
if (!node.optional && !node.wildcard) continue
|
|
@@ -1049,6 +1049,11 @@ function isFrameMoreSpecific(
|
|
|
1049
1049
|
next.statics > prev.statics ||
|
|
1050
1050
|
(next.statics === prev.statics &&
|
|
1051
1051
|
(next.dynamics > prev.dynamics ||
|
|
1052
|
-
(next.dynamics === prev.dynamics &&
|
|
1052
|
+
(next.dynamics === prev.dynamics &&
|
|
1053
|
+
(next.optionals > prev.optionals ||
|
|
1054
|
+
(next.optionals === prev.optionals &&
|
|
1055
|
+
(next.node.isIndex > prev.node.isIndex ||
|
|
1056
|
+
(next.node.isIndex === prev.node.isIndex &&
|
|
1057
|
+
next.depth > prev.depth)))))))
|
|
1053
1058
|
)
|
|
1054
1059
|
}
|
package/src/path.ts
CHANGED
|
@@ -320,22 +320,15 @@ export function interpolatePath({
|
|
|
320
320
|
|
|
321
321
|
if (kind === SEGMENT_TYPE_OPTIONAL_PARAM) {
|
|
322
322
|
const key = path.substring(segment[2], segment[3])
|
|
323
|
-
const prefix = path.substring(start, segment[1])
|
|
324
|
-
const suffix = path.substring(segment[4], end)
|
|
325
323
|
const valueRaw = params[key]
|
|
326
324
|
|
|
327
325
|
// Check if optional parameter is missing or undefined
|
|
328
|
-
if (valueRaw == null)
|
|
329
|
-
if (prefix || suffix) {
|
|
330
|
-
// For optional params with prefix/suffix, keep the prefix/suffix but omit the param
|
|
331
|
-
joined += '/' + prefix + suffix
|
|
332
|
-
}
|
|
333
|
-
// If no prefix/suffix, omit the entire segment
|
|
334
|
-
continue
|
|
335
|
-
}
|
|
326
|
+
if (valueRaw == null) continue
|
|
336
327
|
|
|
337
328
|
usedParams[key] = valueRaw
|
|
338
329
|
|
|
330
|
+
const prefix = path.substring(start, segment[1])
|
|
331
|
+
const suffix = path.substring(segment[4], end)
|
|
339
332
|
const value = encodeParam(key, params, decodeCharMap) ?? ''
|
|
340
333
|
joined += '/' + prefix + value + suffix
|
|
341
334
|
continue
|
package/src/router.ts
CHANGED
|
@@ -1974,7 +1974,7 @@ export class RouterCore<
|
|
|
1974
1974
|
*
|
|
1975
1975
|
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType
|
|
1976
1976
|
*/
|
|
1977
|
-
navigate: NavigateFn = ({ to, reloadDocument, href, ...rest }) => {
|
|
1977
|
+
navigate: NavigateFn = async ({ to, reloadDocument, href, ...rest }) => {
|
|
1978
1978
|
if (!reloadDocument && href) {
|
|
1979
1979
|
try {
|
|
1980
1980
|
new URL(`${href}`)
|
|
@@ -1987,6 +1987,26 @@ export class RouterCore<
|
|
|
1987
1987
|
const location = this.buildLocation({ to, ...rest } as any)
|
|
1988
1988
|
href = location.url
|
|
1989
1989
|
}
|
|
1990
|
+
|
|
1991
|
+
// Check blockers for external URLs unless ignoreBlocker is true
|
|
1992
|
+
if (!rest.ignoreBlocker) {
|
|
1993
|
+
// Cast to access internal getBlockers method
|
|
1994
|
+
const historyWithBlockers = this.history as any
|
|
1995
|
+
const blockers = historyWithBlockers.getBlockers?.() ?? []
|
|
1996
|
+
for (const blocker of blockers) {
|
|
1997
|
+
if (blocker?.blockerFn) {
|
|
1998
|
+
const shouldBlock = await blocker.blockerFn({
|
|
1999
|
+
currentLocation: this.latestLocation,
|
|
2000
|
+
nextLocation: this.latestLocation, // External URLs don't have a next location in our router
|
|
2001
|
+
action: 'PUSH',
|
|
2002
|
+
})
|
|
2003
|
+
if (shouldBlock) {
|
|
2004
|
+
return Promise.resolve()
|
|
2005
|
+
}
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
2009
|
+
|
|
1990
2010
|
if (rest.replace) {
|
|
1991
2011
|
window.location.replace(href)
|
|
1992
2012
|
} else {
|