kwhitley / itty-router

A little router.
MIT License
1.75k stars 78 forks source link

Destructuring request.params partially decodes string #88

Closed manuelbent closed 2 years ago

manuelbent commented 2 years ago

Hi all,

I'm facing this strange behaviour.

If I have a GET endpoint like /entities/:id and I try to pass as :id an encoded string like entities%3A%2Fsource-a_1644431865059, what I get from const { id } = request.params is entities:%2Fsource-a_1644431865059.

Now, why does %3A get decoded into a colon while the rest of the string remains untouched?

Any suggestion anyone?

Thank you!

kwhitley commented 2 years ago

I'm gonna guess that for some reason, by the time itty even sees it, it's partially decoded already. I just ran a test for your exact scenario (including destructuring in the unlikely case that had something to do with it), and it passed just fine...

image image

Wish I could help more!