sanitizeSvgContent = (content) => {
    const {JSDOM} = require('jsdom');
    const createDOMPurify = require('dompurify');
    const window = new JSDOM('').window;
    const DOMPurify = createDOMPurify(window);

    const sanitized = DOMPurify.sanitize(content, {USE_PROFILES: {svg: true, svgFilters: true}});

    // Check whether the sanitized content still contains a non-empty <svg> tag
    const validSvgTag = sanitized?.match(/<svg[^>]*>\s*[\S]+[\S\s]*<\/svg>/);
    if (!sanitized || sanitized.trim() === '' || !validSvgTag) {
        return null;
    }

    return sanitized;
}
@param {String} content
@returns {String | null}

Returns sanitized SVG content, or null if the content is invalid.