Skip to content

Commit

Permalink
Add support for Java class (#591)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcfreire committed Apr 23, 2023
1 parent 1c75cfb commit a40f828
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 3 deletions.
6 changes: 4 additions & 2 deletions core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ export type FileExtension =
| 'jls'
| 'pst'
| 'dwg'
| 'parquet';
| 'parquet'
| 'class';

export type MimeType =
| 'image/jpeg'
Expand Down Expand Up @@ -284,7 +285,8 @@ export type MimeType =
| 'image/jls'
| 'application/vnd.ms-outlook'
| 'image/vnd.dwg'
| 'application/x-parquet';
| 'application/x-parquet'
| 'application/java-vm';

export type FileTypeResult = {
/**
Expand Down
7 changes: 7 additions & 0 deletions core.js
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,13 @@ class FileTypeParser {
};
}

if (this.check([0xCA, 0xFE, 0xBA, 0xBE])) {
return {
ext: 'class',
mime: 'application/java-vm',
};
}

// -- 6-byte signatures --

if (this.check([0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00])) {
Expand Down
Binary file added fixture/fixture.class
Binary file not shown.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@
"jls",
"pst",
"dwg",
"parquet"
"parquet",
"class"
],
"dependencies": {
"readable-web-to-node-stream": "^3.0.2",
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ Returns a `Set<string>` of supported MIME types.
- [`cab`](https://en.wikipedia.org/wiki/Cabinet_(file_format)) - Cabinet file
- [`cfb`](https://en.wikipedia.org/wiki/Compound_File_Binary_Format) - Compount File Binary Format
- [`chm`](https://en.wikipedia.org/wiki/Microsoft_Compiled_HTML_Help) - Microsoft Compiled HTML Help
- [`class`](https://en.wikipedia.org/wiki/Java_class_file) - Java class file
- [`cr2`](https://fileinfo.com/extension/cr2) - Canon Raw image file (v2)
- [`cr3`](https://fileinfo.com/extension/cr3) - Canon Raw image file (v3)
- [`crx`](https://developer.chrome.com/extensions/crx) - Google Chrome extension
Expand Down
2 changes: 2 additions & 0 deletions supported.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export const extensions = [
'pst',
'dwg',
'parquet',
'class',
];

export const mimeTypes = [
Expand Down Expand Up @@ -283,4 +284,5 @@ export const mimeTypes = [
'application/vnd.ms-outlook',
'image/vnd.dwg',
'application/x-parquet',
'application/java-vm',
];

0 comments on commit a40f828

Please sign in to comment.