@tanstack/router-core 1.142.13 → 1.143.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/router.cjs +6 -2
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/esm/router.js +6 -2
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/router.ts +25 -2
package/src/router.ts
CHANGED
|
@@ -1177,6 +1177,7 @@ export class RouterCore<
|
|
|
1177
1177
|
// Before we do any processing, we need to allow rewrites to modify the URL
|
|
1178
1178
|
// build up the full URL by combining the href from history with the router's origin
|
|
1179
1179
|
const fullUrl = new URL(href, this.origin)
|
|
1180
|
+
|
|
1180
1181
|
const url = executeRewriteInput(this.rewrite, fullUrl)
|
|
1181
1182
|
|
|
1182
1183
|
const parsedSearch = this.options.parseSearch(url.search)
|
|
@@ -1187,11 +1188,33 @@ export class RouterCore<
|
|
|
1187
1188
|
|
|
1188
1189
|
const fullPath = url.href.replace(url.origin, '')
|
|
1189
1190
|
|
|
1191
|
+
// Save the internal pathname for route matching (before output rewrite)
|
|
1192
|
+
const internalPathname = url.pathname
|
|
1193
|
+
|
|
1194
|
+
// Compute publicHref by applying the output rewrite.
|
|
1195
|
+
//
|
|
1196
|
+
// The publicHref represents the URL as it should appear in the browser.
|
|
1197
|
+
// This must match what buildLocation computes for the same logical route,
|
|
1198
|
+
// otherwise the server-side redirect check will see a mismatch and trigger
|
|
1199
|
+
// an infinite redirect loop.
|
|
1200
|
+
//
|
|
1201
|
+
// We always apply the output rewrite (not conditionally) because the
|
|
1202
|
+
// incoming URL may have already been transformed by external middleware
|
|
1203
|
+
// before reaching the router. In that case, the input rewrite has nothing
|
|
1204
|
+
// to do, but we still need the output rewrite to reconstruct the correct
|
|
1205
|
+
// public-facing URL.
|
|
1206
|
+
//
|
|
1207
|
+
// Clone the URL to avoid mutating the one used for route matching.
|
|
1208
|
+
const urlForOutput = new URL(url.href)
|
|
1209
|
+
const rewrittenUrl = executeRewriteOutput(this.rewrite, urlForOutput)
|
|
1210
|
+
const publicHref =
|
|
1211
|
+
rewrittenUrl.pathname + rewrittenUrl.search + rewrittenUrl.hash
|
|
1212
|
+
|
|
1190
1213
|
return {
|
|
1191
1214
|
href: fullPath,
|
|
1192
|
-
publicHref
|
|
1215
|
+
publicHref,
|
|
1193
1216
|
url: url,
|
|
1194
|
-
pathname: decodePath(
|
|
1217
|
+
pathname: decodePath(internalPathname),
|
|
1195
1218
|
searchStr,
|
|
1196
1219
|
search: replaceEqualDeep(previousLocation?.search, parsedSearch) as any,
|
|
1197
1220
|
hash: url.hash.split('#').reverse()[0] ?? '',
|