Skip to content

Commit

Permalink
Add support for iCalendar (ics) (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
sripreddyg authored and sindresorhus committed Nov 30, 2018
1 parent 6be8559 commit d9186c9
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
11 changes: 11 additions & 0 deletions fixture/fixture.ics
@@ -0,0 +1,11 @@
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
BEGIN:VEVENT
UID:19970610T172345Z-AF23B2@example.com
DTSTAMP:19970610T172345Z
DTSTART:19970714T170000Z
DTEND:19970715T040000Z
SUMMARY:Bastille Day Party
END:VEVENT
END:VCALENDAR
7 changes: 7 additions & 0 deletions index.js
Expand Up @@ -894,6 +894,13 @@ module.exports = input => {
};
}

if (check([0x42, 0x45, 0x47, 0x49, 0x4E, 0x3A])) {
return {
ext: 'ics',
mime: 'text/calendar'
};
}

return null;
};

Expand Down
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -114,7 +114,8 @@
"odp",
"xml",
"heic",
"wma"
"wma",
"ics"
],
"devDependencies": {
"ava": "*",
Expand Down
1 change: 1 addition & 0 deletions readme.md
Expand Up @@ -179,6 +179,7 @@ The minimum amount of bytes needed to detect a file type. Currently, it's 4100 b
- [`wmv`](https://en.wikipedia.org/wiki/Windows_Media_Video) - Windows Media Video
- [`dcm`](https://en.wikipedia.org/wiki/DICOM#Data_format) - DICOM Image File
- [`mpc`](https://en.wikipedia.org/wiki/Musepack) - Musepack (SV7 & SV8)
- [`ics`](https://en.wikipedia.org/wiki/ICalendar#Data_format) - iCalendar

*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
3 changes: 2 additions & 1 deletion test.js
Expand Up @@ -98,7 +98,8 @@ const types = [
'wv',
'wmv',
'wma',
'dcm'
'dcm',
'ics'
];

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

0 comments on commit d9186c9

Please sign in to comment.