Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for lnk and alias formats #200

Merged
merged 6 commits into from Apr 20, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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'
stroncium marked this conversation as resolved.
Show resolved Hide resolved
stroncium marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment that the MIME is just invented by us? Same with the other one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, technically, x. already indicates it was just invented by random person. I'll add it to readme.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but sometimes it's a common convention shared by multiple tools/software. Here, it's just us using it.

};
}

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'
stroncium marked this conversation as resolved.
Show resolved Hide resolved
};
}
};

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, assigned MIME `application/x.ms.shortcut`
- [`alias`](https://en.wikipedia.org/wiki/Alias_%28Mac_OS%29) - macOS Alias file, assigned MIME `application/x.apple.alias`

*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