-
-
Save andrewlimaza/ccf5e5e792c525f3fa7654e98fd6e4b9 to your computer and use it in GitHub Desktop.
Decodes html entities back to normal html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function decodeHtmlEntities(str) { | |
console.log(str); | |
var special = { | |
"<" : "<", | |
">" : ">", | |
""" : '"', | |
"'" : "'", | |
"'" : "'", | |
"&" : "&", | |
"\\" : "" | |
}; | |
for(var i in special){ | |
while(str.indexOf(i) !== -1){ | |
str = str.replace(i, special[i]); | |
} | |
} | |
return str; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment