Sha256: 84f0f4b507c84369f440369ec25106aaccef2978bb86f09fa603dd4e8b3e5fa4

Contents?: true

Size: 659 Bytes

Versions: 19

Compression:

Stored size: 659 Bytes

Contents

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;
    }
  });
};

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
ela-4.1.6 node_modules/underscore.string/unescapeHTML.js
ela-4.1.5 node_modules/underscore.string/unescapeHTML.js
ela-4.1.4 node_modules/underscore.string/unescapeHTML.js
ela-4.1.3 node_modules/underscore.string/unescapeHTML.js
ela-4.1.2 node_modules/underscore.string/unescapeHTML.js
ela-4.1.1 node_modules/underscore.string/unescapeHTML.js
ela-4.1.0 node_modules/underscore.string/unescapeHTML.js
ela-4.0.0 node_modules/underscore.string/unescapeHTML.js
ela-3.4.3 node_modules/underscore.string/unescapeHTML.js
ela-3.4.2 node_modules/underscore.string/unescapeHTML.js
ela-3.4.0 node_modules/underscore.string/unescapeHTML.js
ela-3.3.1 node_modules/underscore.string/unescapeHTML.js
ela-3.3.0 node_modules/underscore.string/unescapeHTML.js
ela-3.2.0 node_modules/underscore.string/unescapeHTML.js
ela-3.1.1 node_modules/underscore.string/unescapeHTML.js
ela-3.1.0 node_modules/underscore.string/unescapeHTML.js
ela-3.0.0 node_modules/underscore.string/unescapeHTML.js
ela-2.0.0 node_modules/underscore.string/unescapeHTML.js
ela-1.1.0 node_modules/underscore.string/unescapeHTML.js