file-type
Advanced tools
Comparing version 6.2.0 to 7.0.1
53
index.js
@@ -311,2 +311,9 @@ 'use strict'; | ||
if (check([0x0, 0x0, 0x0, 0x1C, 0x66, 0x74, 0x79, 0x70, 0x33, 0x67, 0x70, 0x34])) { | ||
return { | ||
ext: '3gp', | ||
mime: 'video/3gpp' | ||
}; | ||
} | ||
// Check for MP3 header at different starting offsets | ||
@@ -343,6 +350,48 @@ for (let start = 0; start < 2 && start < (buf.length - 16); start++) { | ||
// If 'OggS' in first bytes, then OGG container | ||
if (check([0x4F, 0x67, 0x67, 0x53])) { | ||
// This is a OGG container | ||
// If ' theora' in header. | ||
if (check([0x80, 0x74, 0x68, 0x65, 0x6F, 0x72, 0x61], {offset: 28})) { | ||
return { | ||
ext: 'ogv', | ||
mime: 'video/ogg' | ||
}; | ||
} | ||
// If '\x01video' in header. | ||
if (check([0x01, 0x76, 0x69, 0x64, 0x65, 0x6F, 0x00], {offset: 28})) { | ||
return { | ||
ext: 'ogm', | ||
mime: 'video/ogg' | ||
}; | ||
} | ||
// If ' FLAC' in header https://xiph.org/flac/faq.html | ||
if (check([0x7F, 0x46, 0x4C, 0x41, 0x43], {offset: 28})) { | ||
return { | ||
ext: 'oga', | ||
mime: 'audio/ogg' | ||
}; | ||
} | ||
// 'Speex ' in header https://en.wikipedia.org/wiki/Speex | ||
if (check([0x53, 0x70, 0x65, 0x65, 0x78, 0x20, 0x20], {offset: 28})) { | ||
return { | ||
ext: 'spx', | ||
mime: 'audio/ogg' | ||
}; | ||
} | ||
// If '\x01vorbis' in header | ||
if (check([0x01, 0x76, 0x6F, 0x72, 0x62, 0x69, 0x73], {offset: 28})) { | ||
return { | ||
ext: 'ogg', | ||
mime: 'audio/ogg' | ||
}; | ||
} | ||
// Default OGG container https://www.iana.org/assignments/media-types/application/ogg | ||
return { | ||
ext: 'ogg', | ||
mime: 'audio/ogg' | ||
ext: 'ogx', | ||
mime: 'application/ogg' | ||
}; | ||
@@ -349,0 +398,0 @@ } |
{ | ||
"name": "file-type", | ||
"version": "6.2.0", | ||
"version": "7.0.1", | ||
"description": "Detect the file type of a Buffer/Uint8Array", | ||
@@ -103,3 +103,4 @@ "license": "MIT", | ||
"pptx", | ||
"xlsx" | ||
"xlsx", | ||
"3gp" | ||
], | ||
@@ -106,0 +107,0 @@ "devDependencies": { |
@@ -7,3 +7,7 @@ # file-type [![Build Status](https://travis-ci.org/sindresorhus/file-type.svg?branch=master)](https://travis-ci.org/sindresorhus/file-type) | ||
<a target='_blank' rel='nofollow' href='https://app.codesponsor.io/link/tmkVF4Qm7RNE8e9RVwnim6gU/sindresorhus/file-type'> | ||
<img alt='Sponsor' width='888' height='68' src='https://app.codesponsor.io/embed/tmkVF4Qm7RNE8e9RVwnim6gU/sindresorhus/file-type.svg' /> | ||
</a> | ||
## Install | ||
@@ -147,2 +151,3 @@ | ||
- [`xlsx`](https://en.wikipedia.org/wiki/Office_Open_XML) | ||
- [`3gp`](https://en.wikipedia.org/wiki/3GP_and_3G2) | ||
@@ -149,0 +154,0 @@ *SVG isn't included as it requires the whole file to be read, but you can get it [here](https://github.com/sindresorhus/is-svg).* |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
21125
567
171
1