Files
community-rule/tests/unit/stripImageMetadata.test.ts
T
adilallo 5cbda35e32 Start every Rule private, with a rotating link and files that follow its readers.
New Rules stay off lists until the person who holds the pen turns on a share link, or the team features one. Uploaded files are readable only by those readers, stripped of location metadata, and deleted with the Rule, draft, or account.
2026-11-09 19:54:04 -07:00

21 lines
676 B
TypeScript

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);
});
});