import { CodeBlock } from '../components/CodeBlock'; import type { ResponseRenderer } from './types'; export const svgRenderer: ResponseRenderer = { id: 'svg', matches: (contentType, body) => typeof body === 'string' && contentType.startsWith('image/svg+xml'), views: ['preview', 'raw'], defaultView: 'preview', supportsOverride: false, render: ({ view, body }) => { if (typeof body !== 'string') return null; if (view === 'preview') { // -embedded SVG runs no scripts in any major browser — this // is the safe way to render SVG from untrusted servers. const dataUrl = `data:image/svg+xml;utf8,${encodeURIComponent(body)}`; return ( SVG response ); } return {body}; }, };