@tanstack/router-core 1.132.26 → 1.132.29
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/rewrite.cjs +10 -5
- package/dist/cjs/rewrite.cjs.map +1 -1
- package/dist/cjs/router.cjs +4 -3
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/esm/rewrite.js +10 -5
- package/dist/esm/rewrite.js.map +1 -1
- package/dist/esm/router.js +4 -3
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/rewrite.ts +20 -5
- package/src/router.ts +4 -5
package/package.json
CHANGED
package/src/rewrite.ts
CHANGED
|
@@ -23,13 +23,28 @@ export function rewriteBasepath(opts: {
|
|
|
23
23
|
caseSensitive?: boolean
|
|
24
24
|
}) {
|
|
25
25
|
const trimmedBasepath = trimPath(opts.basepath)
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
const normalizedBasepath = `/${trimmedBasepath}`
|
|
27
|
+
const normalizedBasepathWithSlash = `${normalizedBasepath}/`
|
|
28
|
+
const checkBasepath = opts.caseSensitive
|
|
29
|
+
? normalizedBasepath
|
|
30
|
+
: normalizedBasepath.toLowerCase()
|
|
31
|
+
const checkBasepathWithSlash = opts.caseSensitive
|
|
32
|
+
? normalizedBasepathWithSlash
|
|
33
|
+
: normalizedBasepathWithSlash.toLowerCase()
|
|
34
|
+
|
|
30
35
|
return {
|
|
31
36
|
input: ({ url }) => {
|
|
32
|
-
|
|
37
|
+
const pathname = opts.caseSensitive
|
|
38
|
+
? url.pathname
|
|
39
|
+
: url.pathname.toLowerCase()
|
|
40
|
+
|
|
41
|
+
// Handle exact basepath match (e.g., /my-app -> /)
|
|
42
|
+
if (pathname === checkBasepath) {
|
|
43
|
+
url.pathname = '/'
|
|
44
|
+
} else if (pathname.startsWith(checkBasepathWithSlash)) {
|
|
45
|
+
// Handle basepath with trailing content (e.g., /my-app/users -> /users)
|
|
46
|
+
url.pathname = url.pathname.slice(normalizedBasepath.length)
|
|
47
|
+
}
|
|
33
48
|
return url
|
|
34
49
|
},
|
|
35
50
|
output: ({ url }) => {
|
package/src/router.ts
CHANGED
|
@@ -2230,18 +2230,17 @@ export class RouterCore<
|
|
|
2230
2230
|
|
|
2231
2231
|
resolveRedirect = (redirect: AnyRedirect): AnyRedirect => {
|
|
2232
2232
|
if (!redirect.options.href) {
|
|
2233
|
-
|
|
2233
|
+
const location = this.buildLocation(redirect.options)
|
|
2234
|
+
let href = location.url
|
|
2234
2235
|
if (this.origin && href.startsWith(this.origin)) {
|
|
2235
2236
|
href = href.replace(this.origin, '') || '/'
|
|
2236
2237
|
}
|
|
2237
|
-
redirect.options.href = href
|
|
2238
|
-
redirect.headers.set('Location',
|
|
2238
|
+
redirect.options.href = location.href
|
|
2239
|
+
redirect.headers.set('Location', href)
|
|
2239
2240
|
}
|
|
2240
|
-
|
|
2241
2241
|
if (!redirect.headers.get('Location')) {
|
|
2242
2242
|
redirect.headers.set('Location', redirect.options.href)
|
|
2243
2243
|
}
|
|
2244
|
-
|
|
2245
2244
|
return redirect
|
|
2246
2245
|
}
|
|
2247
2246
|
|