javascript - Clean way to replace all "&#.." characters to normal ones in URL -


couldn't find solution around, so: have url crappy cgaracters like:

var wwwlink = 'http://www.nytimes.com/2014/03/10/business/staking-1-billion-that-herbalife-will-fail-then-ackman-lobbying-to-bring-it-down.html?hp&_r=0'; 

is there clean solution decode possible &#.. thigs normal characters? possible solution have found .replace one, having several .replace calls possible character. of course solution plausable because urls, in cases, have 5 different characters replace, may there's better one?

edit: solution must runnable under node.js.

you can try with:

var div = document.createelement('div');     div.innerhtml = wwwlink;  var output = div.firstchild.nodevalue; 

output:

http://www.nytimes.com/2014/03/10/business/staking-1-billion-that-herbalife-will-fail-then-ackman-lobbying-to-bring-it-down.html?hp&_r=0  

for node.js can give shoot with:

var entities = require('html-entities').xmlentities; entities = new entities(); console.log(entities.decode(wwwlink)); 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -