Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add postscript mimetype #55

Merged
merged 2 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,24 @@ describe("Tests the public API", () => {
expect(result).toContain("image/jpeg");
});

it("detects pdf (Libreoffice export)", () => {
// File created using libreoffice writter export to pdf
const file = getBytes("a.pdf");
const result = filetypemime(file);
expect(result).toContain("application/pdf");
});

it("detects poscript (pdf2ps)", () => {
// File created using pdf2ps from https://www.ghostscript.com
const file = getBytes("a.ps");
const result = filetypemime(file);
expect(result).toContain("application/postscript");

it("detects svg", () => {
// File created using https://png2jpg.com
const file = getBytes("a.svg");
const result = filetypemime(file);
expect(result).toContain("image/svg+xml");

});
});
6 changes: 5 additions & 1 deletion src/model/pattern-tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,11 @@ add("class", ["0xFF", "0xFE"]);
add("class", ["0xFF", "0xFE"]);
add("class", ["0xFF", "0xFE", "0x00", "0x00"]);

add("ps", ["0x25", "0x21", "0x50", "0x53"]);
add("ps", ["0x25", "0x21", "0x50", "0x53"], {
mime: "application/postscript",
extension: ".ps"
}
);
add("pdf", ["0x25", "0x50", "0x44", "0x46"], {
mime: "application/pdf",
extension: "pdf",
Expand Down
Binary file added src/testfiles/a.pdf
Binary file not shown.
Binary file added src/testfiles/a.ps
Binary file not shown.