0
http://www.youtube.com/watch?feature=endscreen&NR=1&v=Ahha3Cqe_fk

For some reason, the string is that. How can I change the & and make them real symbols?

Do I URL encode or decode?

Jacob
  • 77,566
  • 24
  • 149
  • 228
user847495
  • 9,831
  • 17
  • 45
  • 48

3 Answers3

1

$("<div>", {html: "http://www.youtube.com/watch?feature=endscreen&amp;NR=1&amp;v=Ahha3Cqe_fk"}).text()

or

var div = document.createElement("div");
div.innerHTML = "http://www.youtube.com/watch?feature=endscreen&amp;NR=1&amp;v=Ahha3Cqe_fk";
div.firstChild.nodeValue;
Esailija
  • 138,174
  • 23
  • 272
  • 326
0
$url=str_replace("&amp;","&",$url);

It has nothing to do with url encoding. &amp; is an HTML entity of the & symbol.

Pretty much the same deal in JS

url.replace("&amp;","&");
Adam Fowler
  • 1,750
  • 1
  • 17
  • 18
0

Create a DOM element, assign above encoded string to its innerHTML and return nodeValue.

That will be a more robust solution. If you simply want to tackle this one entity an explicit .replace() will do the trick: url.replace(/&amp;/g, "&").

Russell Dias
  • 70,980
  • 5
  • 54
  • 71