Skip to content

Instantly share code, notes, and snippets.

@alekstar79
Last active May 24, 2024 17:01
Show Gist options
  • Save alekstar79/78a9c543f8f1b64fa4b4cdcb1a0d843a to your computer and use it in GitHub Desktop.
Save alekstar79/78a9c543f8f1b64fa4b4cdcb1a0d843a to your computer and use it in GitHub Desktop.
Base64data extractor
/**
* @param {String} data
* @return {{data: String|null, type: String|null}}
*/
export function dataURLMime(data)
{
const decompose = { type: null, data: null },
regexp = /data:(image\/.+);base64,/
decompose.data = data.replace(regexp, (h, t) => {
decompose.type = t
return ''
})
return decompose
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment