I was trying to use the escape command so that I can url encode a String:
var encodedValue : String = escape(blah.hashCodeValue);
But the encodedValue generated wasn't what I'd expect.
1. If string to be url encoded includes a plus sign
if you use escape on b55Cj0bDALCTYeO+evckxmMHPWQ= the encodedValue is b55Cj0bDALCTYeO+evckxmMHPWQ%3D
As you can the plus sign is still present.
I tried an online tool (http://www.opinionatedgeek.com/DotNet/Tools/UrlEncode/Encode.aspx) to see what the string should look like.
So using the online tool, if you url encode b55Cj0bDALCTYeO+evckxmMHPWQ= you get b55Cj0bDALCTYeO%2bevckxmMHPWQ%3d
You can see here that the plus sign is removed and replaced by %2b
2. If string to be url encoded includes a forward slash sign
if you use escape on A6d/rkKds/BCijUDdWwF0AJPTas= you get A6d/rkKds/BCijUDdWwF0AJPTas%3D
As you can see the forward slashes are still present
I would like it to be encoded as "A6d%2frkKds%2fBCijUDdWwF0AJPTas%3d" (/ is replaced with %2f)
Can anyone suggest anything please ?
Use encodeURIComponent method instead of the escape method.
Thank you wingobaxter, much appreciated.