mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-05-01 02:52:29 +02:00
14 lines
318 B
TypeScript
14 lines
318 B
TypeScript
export const decodeBase64Image = (dataString: string) => {
|
|
const matches = dataString.match(/^data:([A-Za-z-+\/]+);base64,(.+)$/);
|
|
let response: any = {};
|
|
|
|
if (matches?.length !== 3) {
|
|
return null;
|
|
}
|
|
|
|
response.type = matches[1];
|
|
response.data = Buffer.from(matches[2], 'base64');
|
|
|
|
return response;
|
|
}
|