MCPcopy Index your code
hub / github.com/darkreader/darkreader / getSolidColorImageURL

Function getSolidColorImageURL

src/inject/dynamic-theme/image.ts:333–341  ·  view source on GitHub ↗
({width, height, useViewBox}: ImageDetails, color: string)

Source from the content-addressed store, hash-verified

331}
332
333export 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
343const xmlEscapeChars: Record<string, string> = {
344 '<': '&lt;',

Callers 1

getBgImageValueFunction · 0.90

Calls 1

escapeXMLFunction · 0.85

Tested by

no test coverage detected