I have this parameter user@ampliflex.co.in
in my url. I want to encode it using javascript, I dont want .
in my url.
Asked
Active
Viewed 200 times
0

Mike Samuel
- 118,113
- 30
- 216
- 245

Romi
- 4,833
- 28
- 81
- 113
-
Take a look at this question: http://stackoverflow.com/questions/332872/how-to-encode-a-url-in-javascript – Rene Pot Sep 29 '11 at 10:00
-
1Can I ask why don't you want `.` in your URL? – Xavi López Sep 29 '11 at 10:02
-
`.` isn't a reserved character in URLs, so it doesn't make sense to URL Encode it. – Quentin Sep 29 '11 at 10:06
1 Answers
1
Even if you encode .
in JavaScript, the browser is allowed to unencode it before sending it to a server.
RFC 3986 section 6.2.2.2. Percent-Encoding Normalization says
The percent-encoding mechanism (Section 2.1) is a frequent source of variance among otherwise identical URIs. In addition to the case normalization issue noted above, some URI producers percent-encode octets that do not require percent-encoding, resulting in URIs that are equivalent to their non-encoded counterparts. These URIs should be normalized by decoding any percent-encoded octet that corresponds to an unreserved character, as described in Section 2.3.
'.'
is an unreserved character in URLs.
unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"

Community
- 1
- 1

Mike Samuel
- 118,113
- 30
- 216
- 245