I'm using Express for my API. When I send request like this:
http://localhost/resource?offer=20% discount
This is what request.query looks like:
{ badge: '20%%20discount' }
I tried to decode it using decodeURIComponent but it threw exception URIError: URI malformed.
Is there any way I can get exact passed string like "20% discount"?
Edit:
I installed qs and urlencode As I'm investigating the problem a little bit (since these are the libraries express is using under the hood to parse the URL) I wonder why browsers don't percent-encode the percent sign?? When I send ?offer=20%25%20discount express parses it correctly.
(https://developer.mozilla.org/en-US/docs/Glossary/percent-encoding) ( % => %25 )