Skip to content

Commit

Permalink
Add a cleanURI function to fix params with special characters
Browse files Browse the repository at this point in the history
  • Loading branch information
cwouam authored Oct 2, 2024
1 parent b7cca36 commit 863dfe4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/fetch-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const fetchHandler = (
} else if (route.httpHandler) {
return route.httpHandler({
req,
params: route.params,
params: cleanURI(route.params),
searchParams,
redisClient: connection,
workersRedisClient: workersConnection
Expand All @@ -97,3 +97,10 @@ export const fetchHandler = (
return new Response("Not found", { status: 404 });
}
}

function cleanURI(params: Record<string, string>) {
for (let [key, value] of Object.entries(params)) {
params[key] = decodeURI(value);
}
return params;
}

0 comments on commit 863dfe4

Please sign in to comment.