@ converted to %40 in GET

Ben Paton picture Ben Paton · Mar 9, 2012 · Viewed 17.4k times · Source

I'm using http://jquery.malsup.com/form/ and I'm posting an e-mail address to a url using GET.

It looks like the @ in the email address is being converted to %40.

Will this be an issue for the site capturing the data?

Answer

Mathias Bynens picture Mathias Bynens · Mar 9, 2012

%40 is the URL-encoded version of @. This conversion only takes place in the URL. The server will still see it as @, and if necessary you can even use JavaScript to decode it:

decodeURIComponent('%40'); // '@'
// or, to encode it back:
encodeURIComponent('@'); // '%40'

Here’s an example of a URL that will get parsed as you’d expect on the server-side:

http://mathiasbynens.be/demo/get?x=%40

If you visit the page, you’ll see that it prints @, not %40.

Here’s an example of a URL that will get parsed as you’d expect on the client-side, by using decodeURIComponent:

http://mothereff.in/byte-counter#%40

If you visit the page, you’ll see that the textarea’s contents are set to @, not %40.