Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

515 B
Raw Blame
/* Adapted from miuuyy/codex-chatgpt-web commit 09877fa21ffdbf20979623ef501046fc02a750d7 (MIT). */
/**
 * Parse a `data:<media-type>;base64,<data>` URL into the file payload Playwright attaches to the
 * ChatGPT composer. Returns null for remote URLs; the browser bridge refuses those explicitly.
 */
export function parseDataUrl(url: string): { mediaType: string; base64: string } | null {
  const m = url.match(/^data:([^;,]+);base64,(.*)$/s);
  if (!m) return null;
  return { mediaType: m[1], base64: m[2] };
}