Skip to content

Commit

Permalink
feat: add postscript mimetype (#55)
Browse files Browse the repository at this point in the history
Co-authored-by: Lars Kölpin-Freese <LarsKoelpin@users.noreply.github.com>
  • Loading branch information
aoliva-sefas and LarsKoelpin authored Feb 29, 2024
1 parent 614161c commit b4d950e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
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.

0 comments on commit b4d950e

Please sign in to comment.