mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 06:59:31 +01:00
inital work
This commit is contained in:
14
packages/core/utils/dataurl.js
Normal file
14
packages/core/utils/dataurl.js
Normal file
@@ -0,0 +1,14 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user