Skip to content
Myr

mime.js

This file

Path

lib/express/mime.js

197 lines · 6.5 KiB · JavaScript

Last changed by

Added "cache views" settingvisionmediabefore adoptionec43eb9

History of this file

Take it

The walk stopped after 200 commits: lines older than 5342d04 point at it.

Docsvisionmediabefore adoption5342d04

lines 1–187why, one step back
1
2// Express - Mime - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)34var types = {5 '3gp' : 'video/3gpp',6 'a' : 'application/octet-stream',7 'ai' : 'application/postscript',8 'aif' : 'audio/x-aiff',9 'aiff' : 'audio/x-aiff',10 'asc' : 'application/pgp-signature',11 'asf' : 'video/x-ms-asf',12 'asm' : 'text/x-asm',13 'asx' : 'video/x-ms-asf',14 'atom' : 'application/atom+xml',15 'au' : 'audio/basic',16 'avi' : 'video/x-msvideo',17 'bat' : 'application/x-msdownload',18 'bin' : 'application/octet-stream',19 'bmp' : 'image/bmp',20 'bz2' : 'application/x-bzip2',21 'c' : 'text/x-c',22 'cab' : 'application/vnd.ms-cab-compressed',23 'cc' : 'text/x-c',24 'chm' : 'application/vnd.ms-htmlhelp',25 'class' : 'application/octet-stream',26 'com' : 'application/x-msdownload',27 'conf' : 'text/plain',28 'cpp' : 'text/x-c',29 'crt' : 'application/x-x509-ca-cert',30 'css' : 'text/css',31 'csv' : 'text/csv',32 'cxx' : 'text/x-c',33 'deb' : 'application/x-debian-package',34 'der' : 'application/x-x509-ca-cert',35 'diff' : 'text/x-diff',36 'djv' : 'image/vnd.djvu',37 'djvu' : 'image/vnd.djvu',38 'dll' : 'application/x-msdownload',39 'dmg' : 'application/octet-stream',40 'doc' : 'application/msword',41 'dot' : 'application/msword',42 'dtd' : 'application/xml-dtd',43 'dvi' : 'application/x-dvi',44 'ear' : 'application/java-archive',45 'eml' : 'message/rfc822',46 'eps' : 'application/postscript',47 'exe' : 'application/x-msdownload',48 'f' : 'text/x-fortran',49 'f77' : 'text/x-fortran',50 'f90' : 'text/x-fortran',51 'flv' : 'video/x-flv',52 'for' : 'text/x-fortran',53 'gem' : 'application/octet-stream',54 'gemspec' : 'text/x-script.ruby',55 'gif' : 'image/gif',56 'gz' : 'application/x-gzip',57 'h' : 'text/x-c',58 'hh' : 'text/x-c',59 'htm' : 'text/html',60 'html' : 'text/html',61 'ico' : 'image/vnd.microsoft.icon',62 'ics' : 'text/calendar',63 'ifb' : 'text/calendar',64 'iso' : 'application/octet-stream',65 'jar' : 'application/java-archive',66 'java' : 'text/x-java-source',67 'jnlp' : 'application/x-java-jnlp-file',68 'jpeg' : 'image/jpeg',69 'jpg' : 'image/jpeg',70 'js' : 'application/javascript',71 'json' : 'application/json',72 'log' : 'text/plain',73 'm3u' : 'audio/x-mpegurl',74 'm4v' : 'video/mp4',75 'man' : 'text/troff',76 'mathml' : 'application/mathml+xml',77 'mbox' : 'application/mbox',78 'mdoc' : 'text/troff',79 'me' : 'text/troff',80 'mid' : 'audio/midi',81 'midi' : 'audio/midi',82 'mime' : 'message/rfc822',83 'mml' : 'application/mathml+xml',84 'mng' : 'video/x-mng',85 'mov' : 'video/quicktime',86 'mp3' : 'audio/mpeg',87 'mp4' : 'video/mp4',88 'mp4v' : 'video/mp4',89 'mpeg' : 'video/mpeg',90 'mpg' : 'video/mpeg',91 'ms' : 'text/troff',92 'msi' : 'application/x-msdownload',93 'odp' : 'application/vnd.oasis.opendocument.presentation',94 'ods' : 'application/vnd.oasis.opendocument.spreadsheet',95 'odt' : 'application/vnd.oasis.opendocument.text',96 'ogg' : 'application/ogg',97 'p' : 'text/x-pascal',98 'pas' : 'text/x-pascal',99 'pbm' : 'image/x-portable-bitmap',100 'pdf' : 'application/pdf',101 'pem' : 'application/x-x509-ca-cert',102 'pgm' : 'image/x-portable-graymap',103 'pgp' : 'application/pgp-encrypted',104 'pkg' : 'application/octet-stream',105 'pl' : 'text/x-script.perl',106 'pm' : 'text/x-script.perl-module',107 'png' : 'image/png',108 'pnm' : 'image/x-portable-anymap',109 'ppm' : 'image/x-portable-pixmap',110 'pps' : 'application/vnd.ms-powerpoint',111 'ppt' : 'application/vnd.ms-powerpoint',112 'ps' : 'application/postscript',113 'psd' : 'image/vnd.adobe.photoshop',114 'py' : 'text/x-script.python',115 'qt' : 'video/quicktime',116 'ra' : 'audio/x-pn-realaudio',117 'rake' : 'text/x-script.ruby',118 'ram' : 'audio/x-pn-realaudio',119 'rar' : 'application/x-rar-compressed',120 'rb' : 'text/x-script.ruby',121 'rdf' : 'application/rdf+xml',122 'roff' : 'text/troff',123 'rpm' : 'application/x-redhat-package-manager',124 'rss' : 'application/rss+xml',125 'rtf' : 'application/rtf',126 'ru' : 'text/x-script.ruby',127 's' : 'text/x-asm',128 'sgm' : 'text/sgml',129 'sgml' : 'text/sgml',130 'sh' : 'application/x-sh',131 'sig' : 'application/pgp-signature',132 'snd' : 'audio/basic',133 'so' : 'application/octet-stream',134 'svg' : 'image/svg+xml',135 'svgz' : 'image/svg+xml',136 'swf' : 'application/x-shockwave-flash',137 't' : 'text/troff',138 'tar' : 'application/x-tar',139 'tbz' : 'application/x-bzip-compressed-tar',140 'tcl' : 'application/x-tcl',141 'tex' : 'application/x-tex',142 'texi' : 'application/x-texinfo',143 'texinfo' : 'application/x-texinfo',144 'text' : 'text/plain',145 'tif' : 'image/tiff',146 'tiff' : 'image/tiff',147 'torrent' : 'application/x-bittorrent',148 'tr' : 'text/troff',149 'txt' : 'text/plain',150 'vcf' : 'text/x-vcard',151 'vcs' : 'text/x-vcalendar',152 'vrml' : 'model/vrml',153 'war' : 'application/java-archive',154 'wav' : 'audio/x-wav',155 'wma' : 'audio/x-ms-wma',156 'wmv' : 'video/x-ms-wmv',157 'wmx' : 'video/x-ms-wmx',158 'wrl' : 'model/vrml',159 'wsdl' : 'application/wsdl+xml',160 'xbm' : 'image/x-xbitmap',161 'xhtml' : 'application/xhtml+xml',162 'xls' : 'application/vnd.ms-excel',163 'xml' : 'application/xml',164 'xpm' : 'image/x-xpixmap',165 'xsl' : 'application/xml',166 'xslt' : 'application/xslt+xml',167 'yaml' : 'text/yaml',168 'yml' : 'text/yaml',169 'zip' : 'application/zip'170}171172/**173 * Return the mime type associated with _path_,174 * where _path_ may be an extension, or full175 * file path.176 *177 * By default 'application/octet-stream' is returned,178 * however this can be altered using the 'default mime type'179 * setting.180 *181 * mime('png') // => 'image/png'182 * mime('.png') // => 'image/png'183 * mime('image.png') // => 'image/png'184 * mime('path/to/image.png') // => 'image/png'185 *186 * @param {string} path187 * @return {string}

Added "cache views" settingvisionmediabefore adoptionec43eb9

line 188why, one step back
188 * @settings 'default mime type'

Docsvisionmediabefore adoption5342d04

lines 189–197why, one step back
189 * @api public
190 */191192exports.mime = function(path) {193 return types[path] || 194 types[extname(path)] || 195 set('default mime type') || 196 'application/octet-stream' 197}