Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

decoding URL in JS not working as expected

Tags:

javascript

I have this url that im trying to decode

var a = 'https%3A%2F%2Fwww.gem.com%2Fextension%3Furl%3D'
var b = decodeURI(a)
console.log(b)

"https%3A%2F%2Fwww.gem.com%2Fextension%3Furl%3D"

What am I doing wrong?

like image 357
Morgan Allen Avatar asked May 16 '26 19:05

Morgan Allen


1 Answers

You need to use decodeURIComponent():

var a = 'https%3A%2F%2Fwww.gem.com%2Fextension%3Furl%3D';
var b = decodeURIComponent(a);
console.log(b);
like image 50
gaetanoM Avatar answered May 18 '26 09:05

gaetanoM



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!