mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-03-31 22:32:28 +00:00
10 lines
292 B
TypeScript
10 lines
292 B
TypeScript
export function decodeDataUrl(url: string) {
|
|
const idx = url.indexOf(",")
|
|
if (idx === -1) return ""
|
|
|
|
const head = url.slice(0, idx)
|
|
const body = url.slice(idx + 1)
|
|
if (head.includes(";base64")) return Buffer.from(body, "base64").toString("utf8")
|
|
return decodeURIComponent(body)
|
|
}
|