diff --git a/lib/common/utils.js b/lib/common/utils.js index e1e433d..3f02f36 100644 --- a/lib/common/utils.js +++ b/lib/common/utils.js @@ -82,11 +82,6 @@ var decodeHTML = require('entities').decodeHTML; function replaceEntityPattern(match, name) { var decoded, code; - decoded = decodeHTML(match); - if (decoded !== match) { - return decoded; - } - if (name.charCodeAt(0) === 0x23/* # */ && DIGITAL_ENTITY_TEST_RE.test(name)) { code = name[1].toLowerCase() === 'x' ? parseInt(name.slice(2), 16) : parseInt(name.slice(1), 10); @@ -94,6 +89,13 @@ function replaceEntityPattern(match, name) { if (isValidEntityCode(code)) { return fromCodePoint(code); } + + return match; + } + + decoded = decodeHTML(match); + if (decoded !== match) { + return decoded; } return match;