Skip to content

Commit 8dd6ffc

Browse files
committed
fix: base64 test
1 parent 3fd7a54 commit 8dd6ffc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,12 @@ class CoCreateFileSystem {
152152
}
153153

154154
let contentType = file['content-type'] || 'text/html';
155-
if (/^[A-Za-z0-9+/]+[=]{0,2}$/.test(src)) {
155+
// const cleanedSrc = src.replace(/\s/g, '');
156+
if (/^data:image\/[a-zA-Z0-9+.-]+;base64,([A-Za-z0-9+/]+={0,2})$/.test(src)) {
156157
src = src.replace(/^data:image\/(png|jpeg|jpg);base64,/, '');
157158
src = Buffer.from(src, 'base64');
159+
} else if (/^([A-Za-z0-9+/]+={0,2})$/.test(src)) {
160+
src = Buffer.from(src, 'base64');
158161
} else if (contentType === 'text/html') {
159162
try {
160163
src = await this.render.HTML(src, organization_id);

0 commit comments

Comments
 (0)