I am using Javascript method decodeURIComponent to decode an encoded URL. Now I am having an issue, that sometimes the URL is get encoded twice during redirection b
There is really simple and fast and trusted way to know if a URL string is encoded or Not.
For Example: decodeURIComponent(decodeURIComponent(encodeURIComponent("SWQgPSA0NjI%3D"))) <> "SWQgPSA0NjI=" ----> Not equal to orginal value then Already encoded
just this code:
var encValue = encodeURIComponent(Value);
try {
if (decodeURIComponent(decodeURIComponent(encValue)) === Value) {
//not encodec yet...so return encoded of val
return encValue;
}
} catch (err) {
//not encodec yet...so return encoded of val
return encValue;
}
return Value //same value returned