file-type 12.4.1 → 12.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +12 -12
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -364,12 +364,12 @@ const fileType = input => {
|
|
|
364
364
|
// `ftyp` box must contain a brand major identifier, which must consist of ISO 8859-1 printable characters.
|
|
365
365
|
// Here we check for 8859-1 printable characters (for simplicity, it's a mask which also catches one non-printable character).
|
|
366
366
|
if (
|
|
367
|
-
|
|
368
|
-
(buffer[8] & 0x60) !== 0x00
|
|
367
|
+
checkString('ftyp', {offset: 4}) &&
|
|
368
|
+
(buffer[8] & 0x60) !== 0x00 // Brand major, first character ASCII?
|
|
369
369
|
) {
|
|
370
370
|
// They all can have MIME `video/mp4` except `application/mp4` special-case which is hard to detect.
|
|
371
371
|
// For some cases, we're specific, everything else falls to `video/mp4` with `mp4` extension.
|
|
372
|
-
const brandMajor = uint8ArrayUtf8ByteString(buffer, 8, 12);
|
|
372
|
+
const brandMajor = uint8ArrayUtf8ByteString(buffer, 8, 12).replace('\0', ' ').trim();
|
|
373
373
|
switch (brandMajor) {
|
|
374
374
|
case 'mif1':
|
|
375
375
|
return {ext: 'heic', mime: 'image/heif'};
|
|
@@ -379,23 +379,23 @@ const fileType = input => {
|
|
|
379
379
|
return {ext: 'heic', mime: 'image/heic'};
|
|
380
380
|
case 'hevc': case 'hevx':
|
|
381
381
|
return {ext: 'heic', mime: 'image/heic-sequence'};
|
|
382
|
-
case 'qt
|
|
382
|
+
case 'qt':
|
|
383
383
|
return {ext: 'mov', mime: 'video/quicktime'};
|
|
384
|
-
case 'M4V
|
|
384
|
+
case 'M4V': case 'M4VH': case 'M4VP':
|
|
385
385
|
return {ext: 'm4v', mime: 'video/x-m4v'};
|
|
386
|
-
case 'M4P
|
|
386
|
+
case 'M4P':
|
|
387
387
|
return {ext: 'm4p', mime: 'video/mp4'};
|
|
388
|
-
case 'M4B
|
|
388
|
+
case 'M4B':
|
|
389
389
|
return {ext: 'm4b', mime: 'audio/mp4'};
|
|
390
|
-
case 'M4A
|
|
390
|
+
case 'M4A':
|
|
391
391
|
return {ext: 'm4a', mime: 'audio/x-m4a'};
|
|
392
|
-
case 'F4V
|
|
392
|
+
case 'F4V':
|
|
393
393
|
return {ext: 'f4v', mime: 'video/mp4'};
|
|
394
|
-
case 'F4P
|
|
394
|
+
case 'F4P':
|
|
395
395
|
return {ext: 'f4p', mime: 'video/mp4'};
|
|
396
|
-
case 'F4A
|
|
396
|
+
case 'F4A':
|
|
397
397
|
return {ext: 'f4a', mime: 'audio/mp4'};
|
|
398
|
-
case 'F4B
|
|
398
|
+
case 'F4B':
|
|
399
399
|
return {ext: 'f4b', mime: 'audio/mp4'};
|
|
400
400
|
default:
|
|
401
401
|
if (brandMajor.startsWith('3g')) {
|