({width, height, useViewBox}: ImageDetails, color: string)
| 331 | } |
| 332 | |
| 333 | export function getSolidColorImageURL({width, height, useViewBox}: ImageDetails, color: string): string { |
| 334 | const size = useViewBox ? `viewBox="0 0 ${width} ${height}"` : `width="${width}" height="${height}"`; |
| 335 | const svg = [ |
| 336 | `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" ${size}>`, |
| 337 | `<rect width="100%" height="100%" fill="${escapeXML(color)}" />`, |
| 338 | '</svg>', |
| 339 | ].join(''); |
| 340 | return `data:image/svg+xml;base64,${btoa(svg)}`; |
| 341 | } |
| 342 | |
| 343 | const xmlEscapeChars: Record<string, string> = { |
| 344 | '<': '<', |
no test coverage detected