mirror of
https://github.com/lexogrine/cs2-react-hud.git
synced 2025-12-10 03:52:48 +01:00
12 lines
390 B
TypeScript
12 lines
390 B
TypeScript
const regex = /^\s*(?:<\?xml[^>]*>\s*)?(?:<!doctype svg[^>]*\s*(?:\[?(?:\s*<![^>]*>\s*)*\]?)*[^>]*>\s*)?(?:<svg[^>]*>[^]*<\/svg>|<svg[^/>]*\/\s*>)\s*$/i;
|
|
|
|
const isSvg = (img: Buffer) =>
|
|
regex.test(
|
|
img
|
|
.toString()
|
|
.replace(/\s*<!Entity\s+\S*\s*(?:"|')[^"]+(?:"|')\s*>/gim, '')
|
|
.replace(/<!--([\s\S]*?)-->/g, '')
|
|
);
|
|
|
|
export default isSvg;
|