const scriptRegex = //g; const linkTagRegex = /]*>/g; const htmlAttribute = /\s+\w+="[^"]*"|\s+\w+='[^']*'|\s+\w+=[^\s>]+/g; function replaceUnicodeEscapes(input: string) { return input.replace(/\\u[\dA-Fa-f]{4}/g, (match) => { // Extract the hexadecimal part and convert it to a character return String.fromCharCode(parseInt(match.slice(2), 16)); }); } export const removeHtmlDetails = (html: string) => { const withoutUnicode = replaceUnicodeEscapes(html); return withoutUnicode .replaceAll(scriptRegex, "") .replaceAll(linkTagRegex, "") .replaceAll(htmlAttribute, "") .replaceAll(/\\"/g, '"') .replaceAll(/\s/g, "") .replaceAll(//g, "
") .replaceAll(//g, "
") .replaceAll(/>/g, "") .replaceAll(/</g, "") .replaceAll(/>/g, "") .replaceAll(/ { const simple1 = removeHtmlDetails(html1); const simple2 = removeHtmlDetails(html2); return simple1 === simple2; };