| ... | @@ -0,0 +1,83 @@ |
| 1 | const std = @import("std"); |
| 2 | const string = []const u8; |
| 3 | |
| 4 | const types = std.ComptimeStringMap(string, .{ |
| 5 | .{ ".aac", "audio/aac" }, |
| 6 | .{ ".abw", "application/x-abiword" }, |
| 7 | .{ ".arc", "application/x-freearc" }, |
| 8 | .{ ".avi", "video/x-msvideo" }, |
| 9 | .{ ".azw", "application/vnd.amazon.ebook" }, |
| 10 | .{ ".bin", "application/octet-stream" }, |
| 11 | .{ ".bmp", "image/bmp" }, |
| 12 | .{ ".bz", "application/x-bzip" }, |
| 13 | .{ ".bz2", "application/x-bzip2" }, |
| 14 | .{ ".cda", "application/x-cdf" }, |
| 15 | .{ ".csh", "application/x-csh" }, |
| 16 | .{ ".css", "text/css" }, |
| 17 | .{ ".csv", "text/csv" }, |
| 18 | .{ ".doc", "application/msword" }, |
| 19 | .{ ".docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document" }, |
| 20 | .{ ".eot", "application/vnd.ms-fontobject" }, |
| 21 | .{ ".epub", "application/epub+zip" }, |
| 22 | .{ ".gz", "application/gzip" }, |
| 23 | .{ ".gif", "image/gif" }, |
| 24 | .{ ".htm", "text/html" }, |
| 25 | .{ ".html", "text/html" }, |
| 26 | .{ ".ico", "image/vnd.microsoft.icon" }, |
| 27 | .{ ".ics", "text/calendar" }, |
| 28 | .{ ".jar", "application/java-archive" }, |
| 29 | .{ ".jpg", "image/jpeg" }, |
| 30 | .{ ".jpeg", "image/jpeg" }, |
| 31 | .{ ".js", "application/javascript" }, |
| 32 | .{ ".json", "application/json" }, |
| 33 | .{ ".jsonld", "application/ld+json" }, |
| 34 | .{ ".mid", "audio/midi" }, |
| 35 | .{ ".mjs", "application/javascript" }, |
| 36 | .{ ".mp3", "audio/mpeg" }, |
| 37 | .{ ".mp4", "video/mp4" }, |
| 38 | .{ ".mpeg", "video/mpeg" }, |
| 39 | .{ ".mpkg", "application/vnd.apple.installer+xml" }, |
| 40 | .{ ".odp", "application/vnd.oasis.opendocument.presentation" }, |
| 41 | .{ ".ods", "application/vnd.oasis.opendocument.spreadsheet" }, |
| 42 | .{ ".odt", "application/vnd.oasis.opendocument.text" }, |
| 43 | .{ ".oga", "audio/ogg" }, |
| 44 | .{ ".ogv", "video/ogg" }, |
| 45 | .{ ".ogx", "application/ogg" }, |
| 46 | .{ ".opus", "audio/opus" }, |
| 47 | .{ ".otf", "font/otf" }, |
| 48 | .{ ".png", "image/png" }, |
| 49 | .{ ".pdf", "application/pdf" }, |
| 50 | .{ ".php", "application/x-httpd-php" }, |
| 51 | .{ ".ppt", "application/vnd.ms-powerpoint" }, |
| 52 | .{ ".pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation" }, |
| 53 | .{ ".rar", "application/vnd.rar" }, |
| 54 | .{ ".rtf", "application/rtf" }, |
| 55 | .{ ".sh", "application/x-sh" }, |
| 56 | .{ ".svg", "image/svg+xml" }, |
| 57 | .{ ".swf", "application/x-shockwave-flash" }, |
| 58 | .{ ".tar", "application/x-tar" }, |
| 59 | .{ ".tiff", "image/tiff" }, |
| 60 | .{ ".ts", "video/mp2t" }, |
| 61 | .{ ".ttf", "font/ttf" }, |
| 62 | .{ ".txt", "text/plain" }, |
| 63 | .{ ".vsd", "application/vnd.visio" }, |
| 64 | .{ ".wav", "audio/wav" }, |
| 65 | .{ ".weba", "audio/webm" }, |
| 66 | .{ ".webm", "video/webm" }, |
| 67 | .{ ".webp", "image/webp" }, |
| 68 | .{ ".woff", "font/woff" }, |
| 69 | .{ ".woff2", "font/woff2" }, |
| 70 | .{ ".xhtml", "application/xhtml+xml" }, |
| 71 | .{ ".xls", "application/vnd.ms-excel" }, |
| 72 | .{ ".xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" }, |
| 73 | .{ ".xml", "application/xml" }, |
| 74 | .{ ".xul", "application/vnd.mozilla.xul+xml" }, |
| 75 | .{ ".zip", "application/zip" }, |
| 76 | .{ ".3gp", "video/3gpp" }, |
| 77 | .{ ".3g2", "video/3gpp2" }, |
| 78 | .{ ".7z", "application/x-7z-compressed" }, |
| 79 | }); |
| 80 | |
| 81 | pub fn typeByExtension(comptime ext: string) ?string { |
| 82 | return types.get(ext); |
| 83 | } |