Skip to content

Commit 1005ab3

Browse files
committed
feat: Identify base64 strings and convert to buffer for response
1 parent 090a5e5 commit 1005ab3

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,7 @@ class CoCreateFileSystem {
144144
}
145145

146146
let contentType = file['content-type'] || 'text/html';
147-
if (contentType === 'image/svg+xml')
148-
contentType = contentType
149-
else if (contentType.startsWith('image/') || contentType.startsWith('audio/') || contentType.startsWith('video/')) {
147+
if (/^[A-Za-z0-9+/]+[=]{0,2}$/.test(src)) {
150148
src = src.replace(/^data:image\/(png|jpeg|jpg);base64,/, '');
151149
src = Buffer.from(src, 'base64');
152150
} else if (contentType === 'text/html') {

0 commit comments

Comments
 (0)