UNPKG

relatt-scraper

Version:

Metascarper

21 lines (19 loc) 455 B
const forceDecoding = (text) => { const regex = /�/i; const encodeChar = { "&amp;": "&", "&quot;": '"', "&amp;quot;": '"', "&lt;": "<", "&gt;": ">", "&apos;": "'", }; let cleanText = text.replace(regex, "").replace(/\s+/g, " ").trim(); return cleanText.replace( /(&quot;|&lt;|&gt;|&apos;|&amp;quot;|&amp;)/g, function (str, item) { return encodeChar[item]; } ); }; module.exports = {forceDecoding}