0

I have a function that gets a query in a url and returns it as a string. However, the string will often contain %20 instead of space, or %27 instead of " ' ".

Is there an easy way to convert these to the intended character without writing table of every single character and its conversion?

1 Answers1

2

decodeURIComponent should solve your problem

var url = http://blah/%20asdf.com
var uri_dec = decodeURIComponent(url);//outputs http://blah/ asdf.com
Maxqueue
  • 2,194
  • 2
  • 23
  • 55