diff --git a/packages/astro/src/core/routing/rewrite.ts b/packages/astro/src/core/routing/rewrite.ts index 678c22ef3cc9..78f70e847386 100644 --- a/packages/astro/src/core/routing/rewrite.ts +++ b/packages/astro/src/core/routing/rewrite.ts @@ -53,9 +53,10 @@ export function findRouteToRewrite({ pathname = pathname.slice(base.length); } + const decodedPathname = decodeURI(pathname); let foundRoute; for (const route of routes) { - if (route.pattern.test(decodeURI(pathname))) { + if (route.pattern.test(decodedPathname)) { foundRoute = route; break; } @@ -65,7 +66,7 @@ export function findRouteToRewrite({ return { routeData: foundRoute, newUrl, - pathname: decodeURI(pathname), + pathname: decodedPathname, }; } else { const custom404 = routes.find((route) => route.route === '/404');