MCPcopy Create free account
hub / github.com/dwgx/WindsurfAPI / parseDataUrl

Function parseDataUrl

src/image.js:38–44  ·  view source on GitHub ↗
(url)

Source from the content-addressed store, hash-verified

36}
37
38export function parseDataUrl(url) {
39 const clean = url.replace(/\s/g, '');
40 const m = clean.match(/^data:(image\/[a-z+]+);base64,(.+)$/i);
41 if (!m) return null;
42 if (m[2].length > MAX_BASE64_LEN) throw new Error(`Image data URL exceeds ${MAX_SIZE} byte limit`);
43 return { base64_data: m[2], mime_type: m[1].toLowerCase() };
44}
45
46// Extract base64 body from a data URL of any mime type. Used for PDF
47// payloads which don't match parseDataUrl's image-only regex.

Callers 1

extractImagesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected