mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-03 15:01:00 +02:00
Use Match for CLI MIME detection
This commit is contained in:
parent
89f9d63b88
commit
a0d98a573b
4 changed files with 51 additions and 22 deletions
22
ts/packages/cli/src/__tests__/library.test.ts
Normal file
22
ts/packages/cli/src/__tests__/library.test.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
import { guessMimeType } from "../commands/library.js";
|
||||
|
||||
describe("library CLI helpers", () => {
|
||||
it("detects known MIME types through the Match-backed extension mapper", () => {
|
||||
expect(guessMimeType("paper.pdf")).toBe("application/pdf");
|
||||
expect(guessMimeType("notes.TXT")).toBe("text/plain");
|
||||
expect(guessMimeType("readme.md")).toBe("text/markdown");
|
||||
expect(guessMimeType("index.html")).toBe("text/html");
|
||||
expect(guessMimeType("partial.htm")).toBe("text/html");
|
||||
expect(guessMimeType("data.json")).toBe("application/json");
|
||||
expect(guessMimeType("table.csv")).toBe("text/csv");
|
||||
expect(guessMimeType("brief.docx")).toBe(
|
||||
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||
);
|
||||
});
|
||||
|
||||
it("falls back for unknown or extensionless paths", () => {
|
||||
expect(guessMimeType("archive.bin")).toBe("application/octet-stream");
|
||||
expect(guessMimeType("README")).toBe("application/octet-stream");
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue