Shubham Sharma
Shubham Sharma

Reputation: 31

Passing query string in a GET request, express converts '+' character in query string into space. How to avoid this?

I am passing certain parameters in query string in a GET request let's say HOST?email=john**+[email protected]. When I try to access these in node express server through req.query.email, I get the value 'john [email protected]'. Express is converting '+**' character into space character. Is there a way that I can stop this encoding?

Upvotes: 2

Views: 820

Answers (1)

Terry Lennox
Terry Lennox

Reputation: 30685

If you want to use the literal + sign, you need to URL encode it to %2b, e.g.

HOST?email=john**%[email protected].

That will decoded correctly by express, e.g.

req.query.email: john**[email protected].

Upvotes: 1

Related Questions