Skip to content

Commit 7b10012

Browse files
authoredOct 13, 2024··
Add support for APK (#679)
1 parent 4dcb8c5 commit 7b10012

File tree

6 files changed

+14
-1
lines changed

6 files changed

+14
-1
lines changed
 

‎core.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ export type FileExtension =
166166
| 'fbx'
167167
| 'vsdx'
168168
| 'vtt'
169+
| 'apk'
169170
; // eslint-disable-line semi-style
170171

171172
export type MimeType =
@@ -318,6 +319,7 @@ export type MimeType =
318319
| 'application/vnd.iccprofile'
319320
| 'application/x.autodesk.fbx'
320321
| 'application/vnd.visio'
322+
| 'application/vnd.android.package-archive'
321323
; // eslint-disable-line semi-style
322324

323325
export type FileTypeResult = {

‎core.js

+7
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,13 @@ export class FileTypeParser {
404404
zipHeader.filename = await tokenizer.readToken(new Token.StringType(zipHeader.filenameLength, 'utf-8'));
405405
await tokenizer.ignore(zipHeader.extraFieldLength);
406406

407+
if (/classes\d*\.dex/.test(zipHeader.filename)) {
408+
return {
409+
ext: 'apk',
410+
mime: 'application/vnd.android.package-archive',
411+
};
412+
}
413+
407414
// Assumes signed `.xpi` from addons.mozilla.org
408415
if (zipHeader.filename === 'META-INF/mozilla.rsa') {
409416
return {

‎fixture/fixture.apk

3.16 MB
Binary file not shown.

‎package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@
216216
"icc",
217217
"fbx",
218218
"vsdx",
219-
"vtt"
219+
"vtt",
220+
"apk"
220221
],
221222
"dependencies": {
222223
"get-stream": "^9.0.1",

‎readme.md

+1
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ abortController.abort(); // Abort file-type reading from the Blob stream.
398398
- [`alias`](https://en.wikipedia.org/wiki/Alias_%28Mac_OS%29) - macOS Alias file
399399
- [`amr`](https://en.wikipedia.org/wiki/Adaptive_Multi-Rate_audio_codec) - Adaptive Multi-Rate audio codec
400400
- [`ape`](https://en.wikipedia.org/wiki/Monkey%27s_Audio) - Monkey's Audio
401+
- [`apk`](https://en.wikipedia.org/wiki/Apk_(file_format)) - Android package format
401402
- [`apng`](https://en.wikipedia.org/wiki/APNG) - Animated Portable Network Graphics
402403
- [`ar`](https://en.wikipedia.org/wiki/Ar_(Unix)) - Archive file
403404
- [`arj`](https://en.wikipedia.org/wiki/ARJ) - Archive file

‎supported.js

+2
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ export const extensions = [
153153
'fbx',
154154
'vsdx',
155155
'vtt',
156+
'apk',
156157
];
157158

158159
export const mimeTypes = [
@@ -305,4 +306,5 @@ export const mimeTypes = [
305306
'application/vnd.iccprofile',
306307
'application/x.autodesk.fbx', // Invented by us
307308
'application/vnd.visio',
309+
'application/vnd.android.package-archive',
308310
];

0 commit comments

Comments
 (0)
Please sign in to comment.