Skip to content

Commit

Permalink
fix: do decode once
Browse files Browse the repository at this point in the history
  • Loading branch information
unprintable123 committed Jan 31, 2025
1 parent 625ebe8 commit 6921e53
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/astro/src/core/routing/rewrite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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');
Expand Down

0 comments on commit 6921e53

Please sign in to comment.