@@ -46,14 +46,11 @@ var ArchiveMap = map[string]bool{
4646var supportedKind = map [string ]string {
4747 "7z" : "application/x-7z-compressed" ,
4848 "Z" : "application/zlib" ,
49- "apk" : "application/gzip" ,
5049 "asm" : "" ,
5150 "bash" : "application/x-bsh" ,
5251 "bat" : "application/bat" ,
5352 "beam" : "application/x-erlang-binary" ,
5453 "bin" : "application/octet-stream" ,
55- "bz2" : "application/x-bzip2" ,
56- "bzip2" : "application/x-bzip2" ,
5754 "c" : "text/x-c" ,
5855 "cc" : "text/x-c" ,
5956 "class" : "application/java-vm" ,
@@ -63,21 +60,16 @@ var supportedKind = map[string]string{
6360 "crontab" : "text/x-crontab" ,
6461 "csh" : "application/x-csh" ,
6562 "cxx" : "text/x-c" ,
66- "deb" : "application/vnd.debian.binary-package" ,
6763 "dll" : "application/octet-stream" ,
6864 "dylib" : "application/x-sharedlib" ,
6965 "elf" : "application/x-elf" ,
7066 "exe" : "application/octet-stream" ,
7167 "expect" : "text/x-expect" ,
7268 "fish" : "text/x-fish" ,
73- "gem" : "application/octet-stream" ,
7469 "go" : "text/x-go" ,
75- "gzip" : "application/gzip" ,
76- "gz" : "application/gzip" ,
7770 "h" : "text/x-h" ,
7871 "hh" : "text/x-h" ,
7972 "html" : "" ,
80- "jar" : "application/java-archive" ,
8173 "java" : "text/x-java" ,
8274 "js" : "application/javascript" ,
8375 "ko" : "application/x-object" ,
@@ -97,29 +89,19 @@ var supportedKind = map[string]string{
9789 "py" : "text/x-python" ,
9890 "pyc" : "application/x-python-code" ,
9991 "rb" : "text/x-ruby" ,
100- "rpm" : "application/x-rpm" ,
10192 "rs" : "text/x-rust" ,
10293 "scpt" : "application/x-applescript" ,
10394 "scptd" : "application/x-applescript" ,
10495 "script" : "text/x-generic-script" ,
10596 "service" : "text/x-systemd" ,
10697 "sh" : "application/x-sh" ,
10798 "so" : "application/x-sharedlib" ,
108- "tar" : "application/x-tar" ,
109- "tar.gz" : "application/gzip" ,
110- "tar.xz" : "application/x-xz" ,
111- "tgz" : "application/gzip" ,
11299 "ts" : "application/typescript" ,
113100 "upx" : "application/x-upx" ,
114- "whl" : "application/x-wheel+zip" ,
115- "xz" : "application/x-xz" ,
116101 "yaml" : "" ,
117102 "yara" : "" ,
118103 "yml" : "" ,
119- "zip" : "application/zip" ,
120104 "zsh" : "application/x-zsh" ,
121- "zst" : "application/zstd" ,
122- "zstd" : "application/zstd" ,
123105}
124106
125107type FileType struct {
@@ -213,6 +195,11 @@ func IsValidUPX(header []byte, path string) (bool, error) {
213195func makeFileType (path string , ext string , mime string ) * FileType {
214196 ext = strings .TrimPrefix (ext , "." )
215197
198+ // Archives are supported
199+ if _ , ok := ArchiveMap [GetExt (path )]; ok {
200+ return & FileType {Ext : ext , MIME : mime }
201+ }
202+
216203 // the only JSON files we currently scan are NPM package metadata, which ends in *package.json
217204 if strings .HasSuffix (path , "package.json" ) {
218205 return & FileType {
@@ -339,8 +326,7 @@ func File(path string) (*FileType, error) {
339326
340327// Path returns a filetype based strictly on file path.
341328func Path (path string ) * FileType {
342- // Trim the leading '.'
343- ext := strings .TrimPrefix (GetExt (path ), "." )
329+ ext := strings .ReplaceAll (filepath .Ext (path ), "." , "" )
344330 mime := supportedKind [ext ]
345331 return makeFileType (path , ext , mime )
346332}
0 commit comments