mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-22 14:39:34 +01:00
15 lines
350 B
JavaScript
15 lines
350 B
JavaScript
|
|
const REGEX = /^data:(?<mime>image\/.+);base64,(?<data>.+)/;
|
||
|
|
|
||
|
|
function toObject(dataurl) {
|
||
|
|
const { groups } = REGEX.exec(dataurl);
|
||
|
|
return groups || {};
|
||
|
|
}
|
||
|
|
|
||
|
|
function fromObject({ type, data }) {
|
||
|
|
//const { groups } = REGEX.exec(dataurl);
|
||
|
|
return `data:${type};base64,${data}`;
|
||
|
|
}
|
||
|
|
|
||
|
|
const dataurl = { toObject, fromObject };
|
||
|
|
export default dataurl;
|