Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

detect-file-type

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

detect-file-type - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

4

package.json
{
"name": "detect-file-type",
"version": "0.0.4",
"version": "0.0.5",
"description": "Detect file type by signature",

@@ -16,3 +16,3 @@ "main": "index.js",

"engines": {
"node": ">=0.10.0"
"node": ">=5.1"
},

@@ -19,0 +19,0 @@ "keywords": [

@@ -5,2 +5,5 @@ # detect-file-type

### Поддерживаемые типы (будет пополнятся)
jpg, png, gif, bmp, webp, tif, cr2, jxr, psd, zip, epub, xpi, tar, rar, gz, bz2, 7z, dmg, mp4, m4v
## Usage

@@ -7,0 +10,0 @@

@@ -1,2 +0,2 @@

# detect-file-type
# detect-file-type [![Build Status](https://travis-ci.org/dimapaloskin/detect-file-type.svg?branch=master)](https://travis-ci.org/dimapaloskin/detect-file-type)

@@ -6,3 +6,3 @@ > Detect file type by signatures. [file-type inspired](https://github.com/sindresorhus/file-type)

### Supported types (will be updated)
jpg, png, gif, bmp, webp, tif, cr2, jxr, psd, zip, epub, xpi, tar
jpg, png, gif, bmp, webp, tif, cr2, jxr, psd, zip, epub, xpi, tar, rar, gz, bz2, 7z, dmg, mp4, m4v

@@ -9,0 +9,0 @@ ## Installation

@@ -154,3 +154,91 @@ [

]
},
{
"type": "rar",
"ext": "rar",
"mime": "application/x-rar-compressed",
"rules": [
{ "type": "equal", "start": 0, "end": 6, "bytes": "526172211a07" },
{ "type": "or", "rules":
[
{ "type": "equal", "start": 6, "end": 7, "bytes": "00" },
{ "type": "equal", "start": 6, "end": 7, "bytes": "01" }
]
}
]
},
{
"type": "gz",
"ext": "gz",
"mime": "application/gzip",
"rules": [
{ "type": "equal", "start": 0, "end": 3, "bytes": "1f8b08" }
]
},
{
"type": "bz2",
"ext": "bz2",
"mime": "application/x-bzip2",
"rules": [
{ "type": "equal", "start": 0, "end": 3, "bytes": "425a68" }
]
},
{
"type": "7z",
"ext": "7z",
"mime": "application/x-7z-compressed",
"rules": [
{ "type": "equal", "start": 0, "end": 6, "bytes": "377abcaf271c" }
]
},
{
"type": "dmg",
"ext": "dmg",
"mime": "application/x-apple-diskimage",
"rules": [
{ "type": "equal", "start": 0, "end": 2, "bytes": "7801" }
]
},
{
"type": "mp4",
"ext": "mp4",
"mime": "video/mp4",
"rules": [
{ "type": "or", "rules":
[
{ "type": "and", "rules":
[
{ "type": "equal", "start": 0, "end": 3, "bytes": "000000" },
{ "type": "or", "rules":
[
{ "type": "equal", "start": 3, "end": 4, "bytes": "18" },
{ "type": "equal", "start": 3, "end": 4, "bytes": "20" }
]
},
{ "type": "equal", "start": 4, "end": 8, "bytes": "66747970" }
]
},
{ "type": "equal", "start": 0, "end": 4, "bytes": "33677035" },
{ "type": "and", "rules":
[
{ "type": "equal", "start": 0, "end": 11, "bytes": "0000001c667479706d7034" },
{ "type": "equal", "start": 16, "end": 28, "bytes": "6d7034316d70343269736f6d" }
]
},
{ "type": "equal", "start": 0, "end": 12, "bytes": "0000001c6674797069736f6d" },
{ "type": "equal", "start": 0, "end": 16, "bytes": "0000001c667479706d70343200000000" }
]
}
]
},
{
"type": "m4v",
"ext": "m4v",
"mime": "video/x-m4v",
"rules": [
{ "type": "equal", "start": 0, "end": 11, "bytes": "0000001c667479704d3456" }
]
}
]

@@ -160,2 +160,79 @@ import {assert} from 'chai';

it('should detect rar', (done) => {
detect.fromFile('./files/fixture.rar', (err, result) => {
assert.equal(err, null);
assert.deepEqual(result, {
ext: 'rar',
mime: 'application/x-rar-compressed'
});
done();
});
});
it('should detect gz', (done) => {
detect.fromFile('./files/fixture.tar.gz', (err, result) => {
assert.equal(err, null);
assert.deepEqual(result, {
ext: 'gz',
mime: 'application/gzip'
});
done();
});
});
it('should detect bz2', (done) => {
detect.fromFile('./files/fixture.bz2', (err, result) => {
assert.equal(err, null);
assert.deepEqual(result, {
ext: 'bz2',
mime: 'application/x-bzip2'
});
done();
});
});
it('should detect 7z', (done) => {
detect.fromFile('./files/fixture.7z', (err, result) => {
assert.equal(err, null);
assert.deepEqual(result, {
ext: '7z',
mime: 'application/x-7z-compressed'
});
done();
});
});
it('should detect dmg', (done) => {
detect.fromFile('./files/fixture.dmg', (err, result) => {
assert.equal(err, null);
assert.deepEqual(result, {
ext: 'dmg',
mime: 'application/x-apple-diskimage'
});
done();
});
});
it('should detect mp4', (done) => {
detect.fromFile('./files/fixture.mp4', (err, result) => {
assert.equal(err, null);
assert.deepEqual(result, {
ext: 'mp4',
mime: 'video/mp4'
});
done();
});
});
it('should detect m4v', (done) => {
detect.fromFile('./files/fixture.m4v', (err, result) => {
assert.equal(err, null);
assert.deepEqual(result, {
ext: 'm4v',
mime: 'video/x-m4v'
});
done();
});
});
});

@@ -166,2 +166,79 @@ 'use strict';

});
it('should detect rar', function (done) {
_index2.default.fromFile('./files/fixture.rar', function (err, result) {
_chai.assert.equal(err, null);
_chai.assert.deepEqual(result, {
ext: 'rar',
mime: 'application/x-rar-compressed'
});
done();
});
});
it('should detect gz', function (done) {
_index2.default.fromFile('./files/fixture.tar.gz', function (err, result) {
_chai.assert.equal(err, null);
_chai.assert.deepEqual(result, {
ext: 'gz',
mime: 'application/gzip'
});
done();
});
});
it('should detect bz2', function (done) {
_index2.default.fromFile('./files/fixture.bz2', function (err, result) {
_chai.assert.equal(err, null);
_chai.assert.deepEqual(result, {
ext: 'bz2',
mime: 'application/x-bzip2'
});
done();
});
});
it('should detect 7z', function (done) {
_index2.default.fromFile('./files/fixture.7z', function (err, result) {
_chai.assert.equal(err, null);
_chai.assert.deepEqual(result, {
ext: '7z',
mime: 'application/x-7z-compressed'
});
done();
});
});
it('should detect dmg', function (done) {
_index2.default.fromFile('./files/fixture.dmg', function (err, result) {
_chai.assert.equal(err, null);
_chai.assert.deepEqual(result, {
ext: 'dmg',
mime: 'application/x-apple-diskimage'
});
done();
});
});
it('should detect mp4', function (done) {
_index2.default.fromFile('./files/fixture.mp4', function (err, result) {
_chai.assert.equal(err, null);
_chai.assert.deepEqual(result, {
ext: 'mp4',
mime: 'video/mp4'
});
done();
});
});
it('should detect m4v', function (done) {
_index2.default.fromFile('./files/fixture.m4v', function (err, result) {
_chai.assert.equal(err, null);
_chai.assert.deepEqual(result, {
ext: 'm4v',
mime: 'video/x-m4v'
});
done();
});
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc