I'm using DomPurify to sanitize SVG code.
It works fine however I would like to show a message if SVG code entered in a textarea is not valid.
I'm trying to compare the SVG code added with the SVG code sanitized. If they are different I will show a message.
function validate() {
if( svgCode.trim() === DOMPurify.sanitize(svgCode).trim() ) {
console.log('All right!');
} else {
console.log('Uuuh-oooh! The SVG code is not valid!');
}
}
validate();
The issue: I keep getting Uuuh-oooh! The SVG code is not valid!
because dompurify turns closing paths like />
into full paths '`.