Initial commit
This commit is contained in:
commit
b0713a844c
19 changed files with 2003 additions and 0 deletions
17
src/split-data-url.ts
Normal file
17
src/split-data-url.ts
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
export function splitDataUrl(dataUrl: string): {
|
||||
mimeType: string | undefined;
|
||||
base64Content: string | undefined;
|
||||
} {
|
||||
try {
|
||||
const [header, base64Content] = dataUrl.split(",");
|
||||
return {
|
||||
mimeType: header?.split(";")[0]?.split(":")[1],
|
||||
base64Content,
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
mimeType: undefined,
|
||||
base64Content: undefined,
|
||||
};
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue