kwhitley / itty-router

A little router.
MIT License
1.7k stars 77 forks source link

Fix special characters in request params #184

Open G4brym opened 10 months ago

G4brym commented 10 months ago

Description

Quote from itty-router-openapi/issues/88 @gimenete

Given an endpoint like this:

router.get(
  "/something/:id",
  (request) => new Response(`id: ${request.params.id}`)
);

Making a query to /something/user%3A1234 returns the following response: id: user%3A1234. While it should be id: user:1234.

The fix here was to decodeURIComponent the request url before parsing the parameters, i've also added a unit test for this, but now this test is failing due to URI malformed.

@kwhitley can you propose a fix here, should i edit the failing test to a valid one?

Type of Change (select one and follow subtasks)

kwhitley commented 8 months ago

Hey there - I somehow missed this one (it came in right before my wedding) - taking a look now.

My gut feeling is that this is prob a safe addition and the test should be modified, but lemme play a bit with it...

kwhitley commented 6 months ago

Targeting v4.1 release for this :)