import { Buffer } from 'buffer' import { JSDOM } from 'jsdom' const XML_HEADER = '' const DOCTYPE = '' export const addSvgHeaderIfMissing = (buffer: ArrayBuffer): Buffer => { const content = Buffer.from(buffer).toString('utf-8') // Create a DOM with the SVG content const dom = new JSDOM(content, { contentType: 'image/svg+xml' }) const document = dom.window.document // Get the serialized content to check if we need to add headers const serialized = dom.serialize() const needsXmlHeader = !serialized.includes('