fix: BufferJSON failing with empty string

This commit is contained in:
Adhiraj Singh
2022-03-01 16:30:11 +05:30
parent a885cfb3f2
commit c00c3da313

View File

@@ -33,8 +33,8 @@ export const BufferJSON = {
},
reviver: (_, value: any) => {
if(typeof value === 'object' && !!value && (value.buffer === true || value.type === 'Buffer')) {
const val = value.data || value.value
return typeof val === 'string' ? Buffer.from(val, 'base64') : Buffer.from(val)
const val = value.data || value.value
return typeof val === 'string' ? Buffer.from(val, 'base64') : Buffer.from(val || [])
}
return value