Skip to content

Commit

Permalink
Add support for ELF (Unix Executable and Linkable Format) (#514)
Browse files Browse the repository at this point in the history
  • Loading branch information
votruongan committed Dec 26, 2021
1 parent 752afb3 commit c4983ea
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core.d.ts
Expand Up @@ -49,6 +49,7 @@ export type FileExtension =
| 'pdf'
| 'epub'
| 'mobi'
| 'elf'
| 'exe'
| 'swf'
| 'rtf'
Expand Down Expand Up @@ -195,6 +196,7 @@ export type MimeType =
| 'audio/wavpack'
| 'audio/amr'
| 'application/pdf'
| 'application/x-elf'
| 'application/x-msdownload'
| 'application/x-shockwave-flash'
| 'application/rtf'
Expand Down
7 changes: 7 additions & 0 deletions core.js
Expand Up @@ -214,6 +214,13 @@ class FileTypeParser {

// -- 4-byte signatures --

if (this.check([0x7F, 0x45, 0x4C, 0x46])) {
return {
ext: 'elf',
mime: 'application/x-elf',
};
}

if (this.check([0x47, 0x49, 0x46])) {
return {
ext: 'gif',
Expand Down
Binary file added fixture/fixture.elf
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -51,6 +51,7 @@
"check",
"is",
"exif",
"elf",
"exe",
"binary",
"buffer",
Expand Down
1 change: 1 addition & 0 deletions readme.md
Expand Up @@ -371,6 +371,7 @@ Returns a `Set<string>` of supported MIME types.
- [`pdf`](https://en.wikipedia.org/wiki/Portable_Document_Format) - Portable Document Format
- [`epub`](https://en.wikipedia.org/wiki/EPUB) - E-book file
- [`mobi`](https://en.wikipedia.org/wiki/Mobipocket) - Mobipocket
- [`elf`](https://en.wikipedia.org/wiki/Executable_and_Linkable_Format) - Unix Executable and Linkable Format
- [`exe`](https://en.wikipedia.org/wiki/.exe) - Executable file
- [`swf`](https://en.wikipedia.org/wiki/SWF) - Adobe Flash Player file
- [`rtf`](https://en.wikipedia.org/wiki/Rich_Text_Format) - Rich Text Format
Expand Down
2 changes: 2 additions & 0 deletions supported.js
Expand Up @@ -47,6 +47,7 @@ export const extensions = [
'amr',
'pdf',
'epub',
'elf',
'exe',
'swf',
'rtf',
Expand Down Expand Up @@ -193,6 +194,7 @@ export const mimeTypes = [
'audio/wavpack',
'audio/amr',
'application/pdf',
'application/x-elf',
'application/x-msdownload',
'application/x-shockwave-flash',
'application/rtf',
Expand Down

0 comments on commit c4983ea

Please sign in to comment.