We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2890b40 commit cbbb51dCopy full SHA for cbbb51d
src/middleware.ts
@@ -5,12 +5,13 @@ import type { MiddlewareHandler } from 'astro';
5
*/
6
export const onRequest: MiddlewareHandler = async ({ request }, next) => {
7
const url = new URL(request.url);
8
+
9
if (url.pathname.includes('/wiki')) {
10
const normalizedPath = url.pathname.toLowerCase().replace(/\/$/, '');
11
12
if (url.pathname !== normalizedPath) {
- url.pathname = normalizedPath;
13
- return Response.redirect(url.toString(), 301);
+ const redirectUrl = `${url.origin}${normalizedPath}${url.search}`;
14
+ return Response.redirect(redirectUrl, 301);
15
}
16
17
0 commit comments