Blame view
node_modules/underscore.string/unescapeHTML.js
659 Bytes
f7563de62
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
var makeString = require('./helper/makeString'); var htmlEntities = require('./helper/htmlEntities'); module.exports = function unescapeHTML(str) { return makeString(str).replace(/\&([^;]+);/g, function(entity, entityCode) { var match; if (entityCode in htmlEntities) { return htmlEntities[entityCode]; /*eslint no-cond-assign: 0*/ } else if (match = entityCode.match(/^#x([\da-fA-F]+)$/)) { return String.fromCharCode(parseInt(match[1], 16)); /*eslint no-cond-assign: 0*/ } else if (match = entityCode.match(/^#(\d+)$/)) { return String.fromCharCode(~~match[1]); } else { return entity; } }); }; |