Skip to content

Commit 6d7d4ab

Browse files
committed
Add gzip detection to file sniffer
1 parent 4fc5ce4 commit 6d7d4ab

File tree

4 files changed

+4
-1
lines changed

4 files changed

+4
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file.
77
### Added
88

99
- archive: Support DEFLATE in Zipper where JS implementations support it in CompressionStream.
10+
- file: Added detection of GZIP files.
1011
- io: Added a skip() method to BitStream to match ByteStream.
1112

1213
## [1.2.1] - 2024-01-19

file/sniffer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const fileSignatures = {
2626
'application/pdf': [[0x25, 0x50, 0x44, 0x46, 0x2d]], // '%PDF-'
2727

2828
// Archive formats:
29+
'application/gzip': [[0x1F, 0x8B]],
2930
'application/x-tar': [ // 'ustar'
3031
[0x75, 0x73, 0x74, 0x61, 0x72, 0x00, 0x30, 0x30],
3132
[0x75, 0x73, 0x74, 0x61, 0x72, 0x20, 0x20, 0x00],

media/media.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ console.warn(`This is not even an alpha-level API. Do not use.`);
33
// A Container Format is a file that embeds multiple data streams into a single file.
44
// Examples:
55
// - the ZIP family (ZIP, JAR, CBZ, EPUB, ODF, OOXML)
6-
// - the ISO-BMFF family (MP4, HEVC, AVIF, MOV/QT, etc)
6+
// - the ISO-BMFF family (MP4, HEVC, HEIC, AVIF, MOV/QT, etc)
77
// - the Matroska family (MKV, WebM)
88
// - the RIFF family (WAV, AVI, WebP)
99
// - the OGG family (OGV, OPUS)

tests/file-sniffer.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ describe('bitjs.file.sniffer', () => {
2424
it('PNG', () => { sniffTest('image/png', [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0xFF]); });
2525
it('WebP', () => { sniffTest('image/webp', [0x52, 0x49, 0x46, 0x46, 0x01, 0x02, 0x03, 0x04, 0x57, 0x45, 0x42, 0x50, 0x81]); });
2626
it('ICO', () => { sniffTest('image/x-icon', [0x00, 0x00, 0x01, 0x00, 0x69])});
27+
it('GZIP', () => { sniffTest('application/gzip', [0x1F, 0x8B, 0x08])});
2728
it('ZIP', () => { sniffTest('application/zip', [0x50, 0x4B, 0x03, 0x04, 0x20]); });
2829
it('ZIP_empty', () => { sniffTest('application/zip', [0x50, 0x4B, 0x05, 0x06, 0x20]); });
2930
it('ZIP_spanned', () => { sniffTest('application/zip', [0x50, 0x4B, 0x07, 0x08, 0x20]); });

0 commit comments

Comments
 (0)