I’m trying to remove the URI encoding from a link, but decodeURI doesn’t seem to be fully working.
My example link is this: /linkout?remoteUrl=http%253a%252f%252fsandbox.yoyogames.com%252fgames%252f171985-h-a-m-heroic-armies-marching
After running the JavaScript script, it looks like this:
http%3a%2f%2fsandbox.yoyogames.com%2fgames%2f171985-h-a-m-heroic-armies-marching
How can I get rid of the remaining not correct codes in the URI?
My decoding code:
var href = $(this).attr('href'); // get the href
var href = decodeURI(href.substring(19)); // remove the outgoing part and remove the escaping
$(this).attr('href', 'http://'+href) // change link on page
the url looks as it was encoded twice, I also suggest to use decodeURIComponent
results in:
“http://sandbox.yoyogames.com/games/171985-h-a-m-heroic-armies-marching”
but you should check why you have the url encoded twice in advance