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