import { describe, expect, it } from "vitest"; import { stripImageMetadata } from "../../lib/server/uploads/stripImageMetadata"; describe("stripImageMetadata", () => { it("drops JPEG APP1 EXIF", () => { const jpeg = Buffer.from([ 0xff, 0xd8, 0xff, 0xe1, 0x00, 0x06, 0x45, 0x78, 0x69, 0x66, 0xff, 0xda, 0x00, 0x01, ]); const out = stripImageMetadata(jpeg, "image/jpeg"); expect(out[0]).toBe(0xff); expect(out[1]).toBe(0xd8); expect(out.includes(0x45)).toBe(false); }); it("leaves non-image bytes unchanged", () => { const pdf = Buffer.from("%PDF-1.4"); expect(stripImageMetadata(pdf, "application/pdf")).toBe(pdf); }); });