Last active
May 24, 2024 17:01
-
-
Save alekstar79/78a9c543f8f1b64fa4b4cdcb1a0d843a to your computer and use it in GitHub Desktop.
Base64data extractor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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