@tanstack/router-core 1.131.12 → 1.131.13
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 +31 -41
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +1 -3
- package/dist/esm/router.d.ts +1 -3
- package/dist/esm/router.js +31 -41
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/router.ts +43 -53
package/package.json
CHANGED
package/src/router.ts
CHANGED
|
@@ -2123,54 +2123,50 @@ export class RouterCore<
|
|
|
2123
2123
|
|
|
2124
2124
|
const handleRedirectAndNotFound = (
|
|
2125
2125
|
match: AnyRouteMatch | undefined,
|
|
2126
|
-
err:
|
|
2126
|
+
err: unknown,
|
|
2127
2127
|
) => {
|
|
2128
|
-
if (isRedirect(err)
|
|
2129
|
-
if (isRedirect(err)) {
|
|
2130
|
-
if (err.redirectHandled) {
|
|
2131
|
-
if (!err.options.reloadDocument) {
|
|
2132
|
-
throw err
|
|
2133
|
-
}
|
|
2134
|
-
}
|
|
2135
|
-
}
|
|
2128
|
+
if (!isRedirect(err) && !isNotFound(err)) return
|
|
2136
2129
|
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
updateMatch(match.id, (prev) => ({
|
|
2145
|
-
...prev,
|
|
2146
|
-
status: isRedirect(err)
|
|
2147
|
-
? 'redirected'
|
|
2148
|
-
: isNotFound(err)
|
|
2149
|
-
? 'notFound'
|
|
2150
|
-
: 'error',
|
|
2151
|
-
isFetching: false,
|
|
2152
|
-
error: err,
|
|
2153
|
-
}))
|
|
2130
|
+
if (
|
|
2131
|
+
isRedirect(err) &&
|
|
2132
|
+
err.redirectHandled &&
|
|
2133
|
+
!err.options.reloadDocument
|
|
2134
|
+
) {
|
|
2135
|
+
throw err
|
|
2136
|
+
}
|
|
2154
2137
|
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2138
|
+
// in case of a redirecting match during preload, the match does not exist
|
|
2139
|
+
if (match) {
|
|
2140
|
+
match._nonReactive.beforeLoadPromise?.resolve()
|
|
2141
|
+
match._nonReactive.loaderPromise?.resolve()
|
|
2142
|
+
match._nonReactive.beforeLoadPromise = undefined
|
|
2143
|
+
match._nonReactive.loaderPromise = undefined
|
|
2158
2144
|
|
|
2159
|
-
|
|
2160
|
-
}
|
|
2145
|
+
const status = isRedirect(err) ? 'redirected' : 'notFound'
|
|
2161
2146
|
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
})
|
|
2172
|
-
throw err
|
|
2147
|
+
updateMatch(match.id, (prev) => ({
|
|
2148
|
+
...prev,
|
|
2149
|
+
status,
|
|
2150
|
+
isFetching: false,
|
|
2151
|
+
error: err,
|
|
2152
|
+
}))
|
|
2153
|
+
|
|
2154
|
+
if (isNotFound(err) && !err.routeId) {
|
|
2155
|
+
err.routeId = match.routeId
|
|
2173
2156
|
}
|
|
2157
|
+
|
|
2158
|
+
match._nonReactive.loadPromise?.resolve()
|
|
2159
|
+
}
|
|
2160
|
+
|
|
2161
|
+
if (isRedirect(err)) {
|
|
2162
|
+
rendered = true
|
|
2163
|
+
err.options._fromLocation = location
|
|
2164
|
+
err.redirectHandled = true
|
|
2165
|
+
err = this.resolveRedirect(err)
|
|
2166
|
+
throw err
|
|
2167
|
+
} else {
|
|
2168
|
+
this._handleNotFound(matches, err, updateMatch)
|
|
2169
|
+
throw err
|
|
2174
2170
|
}
|
|
2175
2171
|
}
|
|
2176
2172
|
|
|
@@ -3063,14 +3059,10 @@ export class RouterCore<
|
|
|
3063
3059
|
_handleNotFound = (
|
|
3064
3060
|
matches: Array<AnyRouteMatch>,
|
|
3065
3061
|
err: NotFoundError,
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
id: string,
|
|
3071
|
-
updater: (match: AnyRouteMatch) => AnyRouteMatch,
|
|
3072
|
-
) => void
|
|
3073
|
-
} = {},
|
|
3062
|
+
updateMatch: (
|
|
3063
|
+
id: string,
|
|
3064
|
+
updater: (match: AnyRouteMatch) => AnyRouteMatch,
|
|
3065
|
+
) => void = this.updateMatch,
|
|
3074
3066
|
) => {
|
|
3075
3067
|
// Find the route that should handle the not found error
|
|
3076
3068
|
// First check if a specific route is requested to show the error
|
|
@@ -3116,9 +3108,7 @@ export class RouterCore<
|
|
|
3116
3108
|
|
|
3117
3109
|
if ((err as any).routerCode === 'BEFORE_LOAD' && routeCursor.parentRoute) {
|
|
3118
3110
|
err.routeId = routeCursor.parentRoute.id
|
|
3119
|
-
this._handleNotFound(matches, err,
|
|
3120
|
-
updateMatch,
|
|
3121
|
-
})
|
|
3111
|
+
this._handleNotFound(matches, err, updateMatch)
|
|
3122
3112
|
}
|
|
3123
3113
|
}
|
|
3124
3114
|
|