1 var makeString = require('./helper/makeString');
2 var htmlEntities = require('./helper/htmlEntities');
4 module.exports = function unescapeHTML(str) {
5 return makeString(str).replace(/\&([^;]+);/g, function(entity, entityCode) {
8 if (entityCode in htmlEntities) {
9 return htmlEntities[entityCode];
10 /*eslint no-cond-assign: 0*/
11 } else if (match = entityCode.match(/^#x([\da-fA-F]+)$/)) {
12 return String.fromCharCode(parseInt(match[1], 16));
13 /*eslint no-cond-assign: 0*/
14 } else if (match = entityCode.match(/^#(\d+)$/)) {
15 return String.fromCharCode(~~match[1]);