'use strict';

function decodeEntities(encodedString) {
    const translate_re = /&(nbsp|amp|quot|lt|gt);/g;
    const translate = {
        nbsp: ' ',
        amp: '&',
        quot: '"',
        lt: '<',
        gt: '>'
    };
    return encodedString.replace(translate_re, function(match, entity) {
        return translate[entity];
    }).replace(/&#(\d+);/gi, function(match, numStr) {
        const num = parseInt(numStr, 10);
        return String.fromCharCode(num);
    });
}

module.exports = {
	decodeEntities: decodeEntities
};

@@ -348,16 +348,20 @@
 ace(/&#(
+x)?(
 %5Cd+);/gi
@@ -377,16 +377,23 @@
 n(match,
+ isHex,
  numStr)
@@ -431,16 +431,29 @@
 (numStr,
+ isHex ? 16 :
  10);%0A  

Fix hex HTML entities