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 CHM #424

Merged
merged 4 commits into from
Dec 21, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 4 additions & 2 deletions core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ declare namespace core {
| 'lzh'
| 'pgp'
| 'asar'
| 'stl';
| 'stl'
| 'chm';

type MimeType =
| 'image/jpeg'
Expand Down Expand Up @@ -264,7 +265,8 @@ declare namespace core {
| 'application/x-lzh-compressed'
| 'application/pgp-encrypted'
| 'application/x-asar'
| 'model/stl';
| 'model/stl'
| 'application/vnd.ms-htmlhelp';

interface FileTypeResult {
/**
Expand Down
7 changes: 7 additions & 0 deletions core.js
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,13 @@ async function _fromTokenizer(tokenizer) {
}
}

if (checkString('ITSF')) {
return {
ext: 'chm',
mime: 'application/vnd.ms-htmlhelp'
};
}

// -- 6-byte signatures --

if (check([0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00])) {
Expand Down
Binary file added fixture/fixture.chm
Binary file not shown.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@
"lzh",
"pgp",
"asar",
"stl"
"stl",
"chm"
],
"devDependencies": {
"@types/node": "^13.1.4",
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ Returns a set of supported MIME types.
- [`pgp`](https://en.wikipedia.org/wiki/Pretty_Good_Privacy) - Pretty Good Privacy
- [`asar`](https://github.com/electron/asar#format) - Archive format primarily used to enclose Electron applications
- [`stl`](https://en.wikipedia.org/wiki/STL_(file_format)) - Standard Tesselated Geometry File Format (ASCII only)
- [`chm`](https://en.wikipedia.org/wiki/Microsoft_Compiled_HTML_Help) - Microsoft Compiled HTML Help

*Pull requests are welcome for additional commonly used file types.*

Expand Down
6 changes: 4 additions & 2 deletions supported.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ module.exports = {
'lzh',
'pgp',
'asar',
'stl'
'stl',
'chm'
],
mimeTypes: [
'image/jpeg',
Expand Down Expand Up @@ -262,6 +263,7 @@ module.exports = {
'application/x-lzh-compressed',
'application/pgp-encrypted',
'application/x-asar',
'model/stl'
'model/stl',
'application/vnd.ms-htmlhelp'
]
};