Files
AFFiNE-Mirror/packages/frontend/workspace/src/blob/util.ts

10 lines
292 B
TypeScript

import isSvg from 'is-svg';
// this has a overhead of converting to string for testing if it is svg.
// is there a more performant way?
export function isSvgBuffer(buffer: Uint8Array) {
const decoder = new TextDecoder('utf-8');
const str = decoder.decode(buffer);
return isSvg(str);
}