Skip to content

Commit

Permalink
Add support for Libpcap File Format (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
greggyd authored and sindresorhus committed Feb 18, 2019
1 parent 557e555 commit 2c77d78
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 2 deletions.
Binary file added fixture/fixture-big-endian.pcap
Binary file not shown.
Binary file added fixture/fixture-little-endian.pcap
Binary file not shown.
7 changes: 7 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,13 @@ module.exports = input => {
};
}

if (check([0xD4, 0xC3, 0xB2, 0xA1]) || check([0xA1, 0xB2, 0xC3, 0xD4])) {
return {
ext: 'pcap',
mime: 'application/vnd.tcpdump.pcap'
};
}

return null;
};

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@
"heic",
"wma",
"ics",
"glb"
"glb",
"pcap"
],
"devDependencies": {
"ava": "^1.0.1",
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ The minimum amount of bytes needed to detect a file type. Currently, it's 4100 b
- [`mpc`](https://en.wikipedia.org/wiki/Musepack) - Musepack (SV7 & SV8)
- [`ics`](https://en.wikipedia.org/wiki/ICalendar#Data_format) - iCalendar
- [`glb`](https://github.com/KhronosGroup/glTF) - GL Transmission Format
- [`pcap`](https://wiki.wireshark.org/Development/LibpcapFileFormat) - Libpcap File Format

*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).*

Expand Down
7 changes: 6 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ const types = [
'wma',
'dcm',
'ics',
'glb'
'glb',
'pcap'
];

// Define an entry here only if the fixture has a different
Expand Down Expand Up @@ -183,6 +184,10 @@ const names = {
mpc: [
'fixture-sv7',
'fixture-sv8'
],
pcap: [
'fixture-big-endian',
'fixture-little-endian'
]
};

Expand Down

0 comments on commit 2c77d78

Please sign in to comment.