diff --git a/core.d.ts b/core.d.ts index e82b1f70..a8b123f0 100644 --- a/core.d.ts +++ b/core.d.ts @@ -166,6 +166,7 @@ export type FileExtension = | 'fbx' | 'vsdx' | 'vtt' + | 'apk' ; // eslint-disable-line semi-style export type MimeType = @@ -318,6 +319,7 @@ export type MimeType = | 'application/vnd.iccprofile' | 'application/x.autodesk.fbx' | 'application/vnd.visio' + | 'application/vnd.android.package-archive' ; // eslint-disable-line semi-style export type FileTypeResult = { diff --git a/core.js b/core.js index ad02b1c7..7beeec5b 100644 --- a/core.js +++ b/core.js @@ -404,6 +404,13 @@ export class FileTypeParser { zipHeader.filename = await tokenizer.readToken(new Token.StringType(zipHeader.filenameLength, 'utf-8')); await tokenizer.ignore(zipHeader.extraFieldLength); + if (/classes\d*\.dex/.test(zipHeader.filename)) { + return { + ext: 'apk', + mime: 'application/vnd.android.package-archive', + }; + } + // Assumes signed `.xpi` from addons.mozilla.org if (zipHeader.filename === 'META-INF/mozilla.rsa') { return { diff --git a/fixture/fixture.apk b/fixture/fixture.apk new file mode 100644 index 00000000..987e0a25 Binary files /dev/null and b/fixture/fixture.apk differ diff --git a/package.json b/package.json index 334741bc..6f50c3fb 100644 --- a/package.json +++ b/package.json @@ -216,7 +216,8 @@ "icc", "fbx", "vsdx", - "vtt" + "vtt", + "apk" ], "dependencies": { "get-stream": "^9.0.1", diff --git a/readme.md b/readme.md index f1bed47b..c4d89f6c 100644 --- a/readme.md +++ b/readme.md @@ -398,6 +398,7 @@ abortController.abort(); // Abort file-type reading from the Blob stream. - [`alias`](https://en.wikipedia.org/wiki/Alias_%28Mac_OS%29) - macOS Alias file - [`amr`](https://en.wikipedia.org/wiki/Adaptive_Multi-Rate_audio_codec) - Adaptive Multi-Rate audio codec - [`ape`](https://en.wikipedia.org/wiki/Monkey%27s_Audio) - Monkey's Audio +- [`apk`](https://en.wikipedia.org/wiki/Apk_(file_format)) - Android package format - [`apng`](https://en.wikipedia.org/wiki/APNG) - Animated Portable Network Graphics - [`ar`](https://en.wikipedia.org/wiki/Ar_(Unix)) - Archive file - [`arj`](https://en.wikipedia.org/wiki/ARJ) - Archive file diff --git a/supported.js b/supported.js index 57857f7e..25294cd9 100644 --- a/supported.js +++ b/supported.js @@ -153,6 +153,7 @@ export const extensions = [ 'fbx', 'vsdx', 'vtt', + 'apk', ]; export const mimeTypes = [ @@ -305,4 +306,5 @@ export const mimeTypes = [ 'application/vnd.iccprofile', 'application/x.autodesk.fbx', // Invented by us 'application/vnd.visio', + 'application/vnd.android.package-archive', ];