dropWizard
dropWizard

Reputation: 3538

decoding URL in JS not working as expected

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?

Upvotes: 3

Views: 257

Answers (1)

gaetanoM
gaetanoM

Reputation: 42044

You need to use decodeURIComponent():

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

Upvotes: 5

Related Questions