Skip to content

Commit

Permalink
Add support for lnk and alias formats (#200)
Browse files Browse the repository at this point in the history
Fixes #192
  • Loading branch information
Yanis Benson authored and sindresorhus committed Apr 20, 2019
1 parent 44b3c34 commit aacd31a
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 3 deletions.
Binary file added fixture/fixture.alias
Binary file not shown.
Binary file added fixture/fixture.lnk
Binary file not shown.
4 changes: 3 additions & 1 deletion index.d.ts
Expand Up @@ -95,7 +95,9 @@ declare namespace fileType {
| 'ics'
| 'glb'
| 'pcap'
| 'dsf';
| 'dsf'
| 'lnk'
| 'alias';

interface FileTypeResult {
/**
Expand Down
14 changes: 14 additions & 0 deletions index.js
Expand Up @@ -919,6 +919,20 @@ const fileType = input => {
mime: 'audio/x-dsf' // Non-standard
};
}

if (check([0x4C, 0x00, 0x00, 0x00, 0x01, 0x14, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46])) {
return {
ext: 'lnk',
mime: 'application/x.ms.shortcut' // Invented by us
};
}

if (check([0x62, 0x6F, 0x6F, 0x6B, 0x00, 0x00, 0x00, 0x00, 0x6D, 0x61, 0x72, 0x6B, 0x00, 0x00, 0x00, 0x00])) {
return {
ext: 'alias',
mime: 'application/x.apple.alias' // Invented by us
};
}
};

module.exports = fileType;
Expand Down
4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -120,7 +120,9 @@
"ics",
"glb",
"pcap",
"dsf"
"dsf",
"lnk",
"alias"
],
"devDependencies": {
"@types/node": "^11.12.2",
Expand Down
2 changes: 2 additions & 0 deletions readme.md
Expand Up @@ -217,6 +217,8 @@ Type: [`stream.Readable`](https://nodejs.org/api/stream.html#stream_class_stream
- [`glb`](https://github.com/KhronosGroup/glTF) - GL Transmission Format
- [`pcap`](https://wiki.wireshark.org/Development/LibpcapFileFormat) - Libpcap File Format
- [`dsf`](https://dsd-guide.com/sites/default/files/white-papers/DSFFileFormatSpec_E.pdf) - Sony DSD Stream File (DSF)
- [`lnk`](https://en.wikipedia.org/wiki/Shortcut_%28computing%29#Microsoft_Windows) - Microsoft Windows file shortcut
- [`alias`](https://en.wikipedia.org/wiki/Alias_%28Mac_OS%29) - macOS Alias file

*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
4 changes: 3 additions & 1 deletion test.js
Expand Up @@ -104,7 +104,9 @@ const types = [
'ics',
'glb',
'pcap',
'dsf'
'dsf',
'lnk',
'alias'
];

// Define an entry here only if the fixture has a different
Expand Down

0 comments on commit aacd31a

Please sign in to comment.