Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
LarsKoelpin authored Feb 29, 2024
2 parents 202c016 + 614161c commit c78e0fa
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "magic-bytes.js",
"version": "1.8.0",
"version": "1.9.0",
"main": "./dist/index.js",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
7 changes: 7 additions & 0 deletions src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,5 +257,12 @@ describe("Tests the public API", () => {
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");

});
});
19 changes: 17 additions & 2 deletions src/model/pattern-tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1020,13 +1020,23 @@ add("nes", ["0x4E", "0x45", "0x53", "0x1A"]);
add(
"tar",
["0x75", "0x73", "0x74", "0x61", "0x72", "0x00", "0x30", "0x30"],
undefined,
{
// As per Mozilla documentation available at:
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
// or wikipedia page:
// https://en.wikipedia.org/wiki/List_of_archive_formats
mime: "application/x-tar",
extension: "tar"
},
0x101
);
add(
"tar",
["0x75", "0x73", "0x74", "0x61", "0x72", "0x20", "0x20", "0x00"],
undefined,
{
mime: "application/x-tar",
extension: "tar"
},
0x101
);

Expand Down Expand Up @@ -1335,4 +1345,9 @@ add(
}
);

add("SVG", ["0x3c", "0x73", "0x76", "0x67"], {
mime: "image/svg+xml",
extension: "svg",
});

export default (): Tree => tree as Tree;
1 change: 1 addition & 0 deletions src/testfiles/a.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c78e0fa

Please sign in to comment.