Skip to content

Commit a40f828

Browse files
authored
Add support for Java class (#591)
1 parent 1c75cfb commit a40f828

File tree

6 files changed

+16
-3
lines changed

6 files changed

+16
-3
lines changed

core.d.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ export type FileExtension =
144144
| 'jls'
145145
| 'pst'
146146
| 'dwg'
147-
| 'parquet';
147+
| 'parquet'
148+
| 'class';
148149

149150
export type MimeType =
150151
| 'image/jpeg'
@@ -284,7 +285,8 @@ export type MimeType =
284285
| 'image/jls'
285286
| 'application/vnd.ms-outlook'
286287
| 'image/vnd.dwg'
287-
| 'application/x-parquet';
288+
| 'application/x-parquet'
289+
| 'application/java-vm';
288290

289291
export type FileTypeResult = {
290292
/**

core.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,13 @@ class FileTypeParser {
917917
};
918918
}
919919

920+
if (this.check([0xCA, 0xFE, 0xBA, 0xBE])) {
921+
return {
922+
ext: 'class',
923+
mime: 'application/java-vm',
924+
};
925+
}
926+
920927
// -- 6-byte signatures --
921928

922929
if (this.check([0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00])) {

fixture/fixture.class

268 Bytes
Binary file not shown.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@
197197
"jls",
198198
"pst",
199199
"dwg",
200-
"parquet"
200+
"parquet",
201+
"class"
201202
],
202203
"dependencies": {
203204
"readable-web-to-node-stream": "^3.0.2",

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ Returns a `Set<string>` of supported MIME types.
364364
- [`cab`](https://en.wikipedia.org/wiki/Cabinet_(file_format)) - Cabinet file
365365
- [`cfb`](https://en.wikipedia.org/wiki/Compound_File_Binary_Format) - Compount File Binary Format
366366
- [`chm`](https://en.wikipedia.org/wiki/Microsoft_Compiled_HTML_Help) - Microsoft Compiled HTML Help
367+
- [`class`](https://en.wikipedia.org/wiki/Java_class_file) - Java class file
367368
- [`cr2`](https://fileinfo.com/extension/cr2) - Canon Raw image file (v2)
368369
- [`cr3`](https://fileinfo.com/extension/cr3) - Canon Raw image file (v3)
369370
- [`crx`](https://developer.chrome.com/extensions/crx) - Google Chrome extension

supported.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ export const extensions = [
142142
'pst',
143143
'dwg',
144144
'parquet',
145+
'class',
145146
];
146147

147148
export const mimeTypes = [
@@ -283,4 +284,5 @@ export const mimeTypes = [
283284
'application/vnd.ms-outlook',
284285
'image/vnd.dwg',
285286
'application/x-parquet',
287+
'application/java-vm',
286288
];

0 commit comments

Comments
 (0)