Skip to content

Commit

Permalink
Add support for APK (#679)
Browse files Browse the repository at this point in the history
  • Loading branch information
epicmet authored Oct 13, 2024
1 parent 4dcb8c5 commit 7b10012
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export type FileExtension =
| 'fbx'
| 'vsdx'
| 'vtt'
| 'apk'
; // eslint-disable-line semi-style

export type MimeType =
Expand Down Expand Up @@ -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 = {
Expand Down
7 changes: 7 additions & 0 deletions core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Binary file added fixture/fixture.apk
Binary file not shown.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@
"icc",
"fbx",
"vsdx",
"vtt"
"vtt",
"apk"
],
"dependencies": {
"get-stream": "^9.0.1",
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions supported.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ export const extensions = [
'fbx',
'vsdx',
'vtt',
'apk',
];

export const mimeTypes = [
Expand Down Expand Up @@ -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',
];

0 comments on commit 7b10012

Please sign in to comment.