Skip to content

Commit 0ee6c01

Browse files
committed
fix
1 parent 6aecd69 commit 0ee6c01

File tree

1 file changed

+37
-49
lines changed

1 file changed

+37
-49
lines changed

src/Util.php

Lines changed: 37 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -91,66 +91,54 @@ class Util {
9191
510 => 'Not Extended'
9292
];
9393

94-
private static $_mime_types = [
95-
'txt' => 'text/plain',
96-
'htm' => 'text/html',
97-
'html' => 'text/html',
98-
'php' => 'text/html',
99-
'css' => 'text/css',
100-
'js' => 'application/javascript',
101-
'json' => 'application/json',
102-
'xml' => 'application/xml',
103-
'swf' => 'application/x-shockwave-flash',
104-
'flv' => 'video/x-flv',
94+
private static $_mime_extensions = [
95+
'text/plain' => 'txt',
96+
'text/html' => 'html',
97+
'text/css' => 'css',
98+
'application/javascript' => 'js',
99+
'application/json' => 'json',
100+
'application/xml' => 'xml',
101+
'application/x-shockwave-flash' => 'swf',
102+
'video/x-flv' => 'flv',
105103

106104
// images
107-
'png' => 'image/png',
108-
'jpe' => 'image/jpeg',
109-
'jpeg' => 'image/jpeg',
110-
'jpg' => 'image/jpeg',
111-
'gif' => 'image/gif',
112-
'bmp' => 'image/bmp',
113-
'ico' => 'image/vnd.microsoft.icon',
114-
'tiff' => 'image/tiff',
115-
'tif' => 'image/tiff',
116-
'svg' => 'image/svg+xml',
117-
'svgz' => 'image/svg+xml',
105+
'image/png' => 'png',
106+
'image/jpeg' => 'jpg',
107+
'image/gif' => 'gif',
108+
'image/bmp' => 'bmp',
109+
'image/vnd.microsoft.icon' => 'ico',
110+
'image/tiff' => 'tiff',
111+
'image/svg+xml' => 'svg',
118112

119113
// archives
120-
'zip' => 'application/zip',
121-
'rar' => 'application/x-rar-compressed',
122-
'exe' => 'application/x-msdownload',
123-
'msi' => 'application/x-msdownload',
124-
'cab' => 'application/vnd.ms-cab-compressed',
114+
'application/zip' => 'zip',
115+
'application/x-rar-compressed' => 'rar',
116+
'application/x-msdownload' => 'exe',
117+
'application/vnd.ms-cab-compressed' => 'cab',
125118

126119
// audio/video
127-
'mp3' => 'audio/mpeg',
128-
'qt' => 'video/quicktime',
129-
'mov' => 'video/quicktime',
130-
'wmv' => 'video/x-ms-wmv',
131-
'mp4' => 'video/mp4',
132-
'mp4a' => 'audio/mp4',
133-
'mpeg' => 'video/mpeg',
120+
'audio/mpeg' => 'mp3',
121+
'video/quicktime' => 'mov',
122+
'video/x-ms-wmv' => 'wmv',
123+
'video/mp4' => 'mp4',
124+
'video/mpeg' => 'mpeg',
134125

135126
// adobe
136-
'pdf' => 'application/pdf',
137-
'psd' => 'image/vnd.adobe.photoshop',
138-
'ai' => 'application/postscript',
139-
'eps' => 'application/postscript',
140-
'ps' => 'application/postscript',
141-
'tiff' => 'image/tiff',
127+
'application/pdf' => 'pdf',
128+
'image/vnd.adobe.photoshop' => 'psd',
129+
'application/postscript' => 'eps',
142130

143131
// ms office
144-
'doc' => 'application/msword',
145-
'rtf' => 'application/rtf',
146-
'xls' => 'application/vnd.ms-excel',
147-
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
148-
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
149-
'ppt' => 'application/vnd.ms-powerpoint',
132+
'application/msword' => 'doc',
133+
'application/rtf' => 'rtf',
134+
'application/vnd.ms-excel' => 'xls',
135+
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'xlsx',
136+
'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'docx',
137+
'application/vnd.ms-powerpoint' => 'ppt',
150138

151139
// open office
152-
'odt' => 'application/vnd.oasis.opendocument.text',
153-
'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
140+
'application/vnd.oasis.opendocument.text' => 'odt',
141+
'application/vnd.oasis.opendocument.spreadsheet' => 'ods',
154142
];
155143

156144
/**
@@ -170,7 +158,7 @@ public static function getHttpStatus($code) {
170158
* @return string The extension
171159
*/
172160
public static function getExtension($mime_type) {
173-
return array_search(strtolower($mime_type), self::$_mime_types);
161+
return self::get($mime_type, self::$_mime_extensions);
174162
}
175163

176164
public static function get($field, $source = null, $default = null, $possible_values = []) {

0 commit comments

Comments
 (0)