Skip to content

Commit

Permalink
Add support for .lz4 file format
Browse files Browse the repository at this point in the history
Resolves: #444
  • Loading branch information
Borewit committed Dec 15, 2024
1 parent e99257d commit de3bf28
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 1 deletion.
7 changes: 7 additions & 0 deletions core.js
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,13 @@ export class FileTypeParser {
};
}

if (this.check([0x04, 0x22, 0x4D, 0x18])) {
return {
ext: 'lz4',
mime: 'application/x-lz4', // Invented by us
};
}

// -- 5-byte signatures --

if (this.check([0x4F, 0x54, 0x54, 0x4F, 0x00])) {
Expand Down
Binary file added fixture/fixture.lz4
Binary file not shown.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@
"vsdx",
"vtt",
"apk",
"drc"
"drc",
"lz4"
],
"dependencies": {
"strtok3": "^10.0.0",
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ abortController.abort(); // Abort file-type reading from the Blob stream.
- [`ktx`](https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/) - OpenGL and OpenGL ES textures
- [`lnk`](https://en.wikipedia.org/wiki/Shortcut_%28computing%29#Microsoft_Windows) - Microsoft Windows file shortcut
- [`lz`](https://en.wikipedia.org/wiki/Lzip) - Archive file
- [`lz4`](https://en.wikipedia.org/wiki/LZ4_(compression_algorithm)) - Compressed archive created by one of a variety of LZ4 compression utilities
- [`lzh`](https://en.wikipedia.org/wiki/LHA_(file_format)) - LZH archive
- [`m4a`](https://en.wikipedia.org/wiki/M4A) - Audio-only MPEG-4 files
- [`m4b`](https://en.wikipedia.org/wiki/M4B) - Audiobook and podcast MPEG-4 files, which also contain metadata including chapter markers, images, and hyperlinks
Expand Down
2 changes: 2 additions & 0 deletions supported.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export const extensions = [
'vtt',
'apk',
'drc',
'lz4',
];

export const mimeTypes = [
Expand Down Expand Up @@ -309,4 +310,5 @@ export const mimeTypes = [
'application/vnd.visio',
'application/vnd.android.package-archive',
'application/vnd.google.draco', // Invented by us
'application/x-lz4', // Invented by us
];
3 changes: 3 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ const names = {
'fixture-vtt-tab',
'fixture-vtt-eof',
],
lz4: [
'fixture',
],
};

// Define an entry here only if the file type has potential
Expand Down

0 comments on commit de3bf28

Please sign in to comment.