├── .eslintrc.json ├── .gitignore ├── .release-it.json ├── .travis.yml ├── LICENSE ├── README.md ├── dist ├── browser-mime-db.json ├── index.js └── index.js.map ├── env.sample ├── mime-types ├── .eslintignore ├── .eslintrc.yml ├── .gitignore ├── .travis.yml ├── HISTORY.md ├── LICENSE ├── README.md ├── index.js ├── package.json └── test │ ├── .eslintrc.yml │ └── test.js ├── package-lock.json ├── package.json ├── src └── initial-db.json ├── test ├── chromium-types.js ├── test.js └── webkit-types.js ├── tools ├── build-db.js ├── server-cli.js └── server.js └── views ├── layouts └── main.handlebars ├── mime.handlebars └── public └── index.js /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "commonjs": true, 5 | "node": true, 6 | "es6": true, 7 | "mocha": true 8 | }, 9 | "extends": "eslint:recommended", 10 | "globals": { 11 | "Atomics": "readonly", 12 | "SharedArrayBuffer": "readonly" 13 | }, 14 | "parserOptions": { 15 | "ecmaVersion": 2018 16 | }, 17 | "rules": { 18 | "no-console": 0 19 | } 20 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (https://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # TypeScript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | # next.js build output 61 | .next 62 | 63 | # Parcel cache 64 | .cache 65 | -------------------------------------------------------------------------------- /.release-it.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "beforeBump": "npm run build", 4 | "changelogCommand": "git log --pretty=format:'* %s (%h)' [REV_RANGE]" 5 | }, 6 | "git": { 7 | "pushRepo": "git@github.com:humphd/browser-mime.git", 8 | "tagName": "v%s" 9 | }, 10 | "npm": { 11 | "publish": true 12 | }, 13 | "github": { 14 | "release": true, 15 | "releaseName": "browser-mime %s Released" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | os: 4 | - linux 5 | - osx 6 | - windows 7 | 8 | node_js: 9 | - "lts/*" 10 | - "node" 11 | 12 | cache: npm 13 | 14 | before_script: 15 | - npm run eslint 16 | - npm run build 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 David Humphrey 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # browser-mime [![Build Status](https://travis-ci.org/humphd/browser-mime.svg?branch=master)](https://travis-ci.org/humphd/browser-mime) 2 | 3 | MIME types that can be parsed/rendered in most browsers. The list is automatically 4 | generated from [mime-db](https://github.com/jshttp/mime-db). Manual types and 5 | extension information is also included in [src/initial-db.json](src/initial-db.json). 6 | 7 | To rebuild the JS library in `dist/`: 8 | 9 | ``` 10 | npm build 11 | ``` 12 | 13 | To regenerate the database: 14 | 15 | ``` 16 | npm run build-db 17 | ``` 18 | 19 | This will reproduce [`browser-mime-db.json`](dist/browser-mime-db.json) 20 | by attempting to load an empty file of every type in [mime-db](https://www.npmjs.com/package/mime-db), and keep track of which ones Chrome was able to download 21 | and use vs. prompting the user with a Download popup. 22 | 23 | The [mime-types](https://github.com/jshttp/mime-types.git) project is included as a squashed subtree in [mime-types/](mime-types). To update the subtree code use `npm run update-mime-types`. 24 | 25 | ## API 26 | 27 | The API is identical too, and shares the same code as, [mime-types](https://github.com/jshttp/mime-types.git). From their README: 28 | 29 | ```js 30 | var mime = require('mime-types') 31 | ``` 32 | 33 | All functions return `false` if input is invalid or not found. 34 | 35 | ### mime.lookup(path) 36 | 37 | Lookup the content-type associated with a file. 38 | 39 | ```js 40 | mime.lookup('json') // 'application/json' 41 | mime.lookup('.md') // 'text/markdown' 42 | mime.lookup('file.html') // 'text/html' 43 | mime.lookup('folder/file.js') // 'application/javascript' 44 | mime.lookup('folder/.htaccess') // false 45 | 46 | mime.lookup('cats') // false 47 | ``` 48 | 49 | ### mime.contentType(type) 50 | 51 | Create a full content-type header given a content-type or extension. 52 | When given an extension, `mime.lookup` is used to get the matching 53 | content-type, otherwise the given content-type is used. Then if the 54 | content-type does not already have a `charset` parameter, `mime.charset` 55 | is used to get the default charset and add to the returned content-type. 56 | 57 | ```js 58 | mime.contentType('markdown') // 'text/x-markdown; charset=utf-8' 59 | mime.contentType('file.json') // 'application/json; charset=utf-8' 60 | mime.contentType('text/html') // 'text/html; charset=utf-8' 61 | mime.contentType('text/html; charset=iso-8859-1') // 'text/html; charset=iso-8859-1' 62 | 63 | // from a full path 64 | mime.contentType(path.extname('/path/to/file.json')) // 'application/json; charset=utf-8' 65 | ``` 66 | 67 | ### mime.extension(type) 68 | 69 | Get the default extension for a content-type. 70 | 71 | ```js 72 | mime.extension('application/octet-stream') // 'bin' 73 | ``` 74 | 75 | ### mime.charset(type) 76 | 77 | Lookup the implied default charset of a content-type. 78 | 79 | ```js 80 | mime.charset('text/markdown') // 'UTF-8' 81 | ``` 82 | 83 | ### var type = mime.types[extension] 84 | 85 | A map of content-types by extension. 86 | 87 | ### [extensions...] = mime.extensions[type] 88 | 89 | A map of extensions by content-type. 90 | -------------------------------------------------------------------------------- /dist/browser-mime-db.json: -------------------------------------------------------------------------------- 1 | { 2 | "application/xhtml+xml": { 3 | "extensions": [ 4 | "xhtml", 5 | "xht", 6 | "xhtm" 7 | ] 8 | }, 9 | "text/html": { 10 | "extensions": [ 11 | "html", 12 | "htm", 13 | "shtml", 14 | "shtm" 15 | ] 16 | }, 17 | "image/apng": { 18 | "extensions": [ 19 | "apng" 20 | ] 21 | }, 22 | "application/wasm": { 23 | "extensions": [ 24 | "wasm" 25 | ] 26 | }, 27 | "audio/mp3": { 28 | "extensions": [ 29 | "mp3" 30 | ] 31 | }, 32 | "audio/wav": { 33 | "extensions": [ 34 | "wav" 35 | ] 36 | }, 37 | "audio/x-flac": { 38 | "extensions": [ 39 | "flac" 40 | ] 41 | }, 42 | "audio/x-m4a": { 43 | "extensions": [ 44 | "m4a" 45 | ] 46 | }, 47 | "application/javascript": { 48 | "charset": "UTF-8", 49 | "extensions": [ 50 | "js", 51 | "mjs" 52 | ] 53 | }, 54 | "video/x-m4v": { 55 | "extensions": [ 56 | "m4v" 57 | ] 58 | }, 59 | "video/ogg": { 60 | "extensions": [ 61 | "ogv", 62 | "ogm" 63 | ] 64 | }, 65 | "application/epub+zip": { 66 | "extensions": [ 67 | "epub" 68 | ] 69 | }, 70 | "application/pdf": { 71 | "extensions": [ 72 | "pdf" 73 | ] 74 | }, 75 | "video/mpeg": { 76 | "extensions": [ 77 | "mpeg", 78 | "mpg", 79 | "mpe", 80 | "m1v", 81 | "m2v" 82 | ] 83 | }, 84 | "audio/mpeg": { 85 | "extensions": [ 86 | "mpga", 87 | "mp2", 88 | "mp2a", 89 | "mp3", 90 | "m2a", 91 | "m3a" 92 | ] 93 | }, 94 | "font/otf": { 95 | "extensions": [ 96 | "otf" 97 | ] 98 | }, 99 | "font/ttf": { 100 | "extensions": [ 101 | "ttf" 102 | ] 103 | }, 104 | "font/woff": { 105 | "extensions": [ 106 | "woff" 107 | ] 108 | }, 109 | "font/woff2": { 110 | "extensions": [ 111 | "woff2" 112 | ] 113 | }, 114 | "application/atom+xml": { 115 | "extensions": [ 116 | "atom" 117 | ] 118 | }, 119 | "application/ecmascript": { 120 | "extensions": [ 121 | "ecma", 122 | "es" 123 | ] 124 | }, 125 | "application/geo+json": { 126 | "extensions": [ 127 | "geojson" 128 | ] 129 | }, 130 | "application/json": { 131 | "charset": "UTF-8", 132 | "extensions": [ 133 | "json", 134 | "map" 135 | ] 136 | }, 137 | "application/jsonml+json": { 138 | "extensions": [ 139 | "jsonml" 140 | ] 141 | }, 142 | "application/ld+json": { 143 | "extensions": [ 144 | "jsonld" 145 | ] 146 | }, 147 | "application/manifest+json": { 148 | "charset": "UTF-8", 149 | "extensions": [ 150 | "webmanifest" 151 | ] 152 | }, 153 | "application/ogg": { 154 | "extensions": [ 155 | "ogx" 156 | ] 157 | }, 158 | "application/rss+xml": { 159 | "extensions": [ 160 | "rss" 161 | ] 162 | }, 163 | "application/x-web-app-manifest+json": { 164 | "extensions": [ 165 | "webapp" 166 | ] 167 | }, 168 | "application/xml": { 169 | "extensions": [ 170 | "xml", 171 | "xsl", 172 | "xsd", 173 | "rng" 174 | ] 175 | }, 176 | "audio/mp4": { 177 | "extensions": [ 178 | "m4a", 179 | "mp4a" 180 | ] 181 | }, 182 | "audio/ogg": { 183 | "extensions": [ 184 | "oga", 185 | "ogg", 186 | "spx" 187 | ] 188 | }, 189 | "audio/webm": { 190 | "extensions": [ 191 | "weba" 192 | ] 193 | }, 194 | "audio/x-wav": { 195 | "extensions": [ 196 | "wav" 197 | ] 198 | }, 199 | "image/bmp": { 200 | "extensions": [ 201 | "bmp" 202 | ] 203 | }, 204 | "image/gif": { 205 | "extensions": [ 206 | "gif" 207 | ] 208 | }, 209 | "image/jpeg": { 210 | "extensions": [ 211 | "jpeg", 212 | "jpg", 213 | "jpe" 214 | ] 215 | }, 216 | "image/png": { 217 | "extensions": [ 218 | "png" 219 | ] 220 | }, 221 | "image/svg+xml": { 222 | "extensions": [ 223 | "svg", 224 | "svgz" 225 | ] 226 | }, 227 | "image/vnd.microsoft.icon": { 228 | "extensions": [ 229 | "ico" 230 | ] 231 | }, 232 | "image/webp": { 233 | "extensions": [ 234 | "webp" 235 | ] 236 | }, 237 | "image/x-icon": { 238 | "extensions": [ 239 | "ico" 240 | ] 241 | }, 242 | "image/x-xbitmap": { 243 | "extensions": [ 244 | "xbm" 245 | ] 246 | }, 247 | "text/cache-manifest": { 248 | "extensions": [ 249 | "appcache", 250 | "manifest" 251 | ] 252 | }, 253 | "text/coffeescript": { 254 | "extensions": [ 255 | "coffee", 256 | "litcoffee" 257 | ] 258 | }, 259 | "text/css": { 260 | "charset": "UTF-8", 261 | "extensions": [ 262 | "css" 263 | ] 264 | }, 265 | "text/jade": { 266 | "extensions": [ 267 | "jade" 268 | ] 269 | }, 270 | "text/jsx": { 271 | "extensions": [ 272 | "jsx" 273 | ] 274 | }, 275 | "text/less": { 276 | "extensions": [ 277 | "less" 278 | ] 279 | }, 280 | "text/markdown": { 281 | "extensions": [ 282 | "markdown", 283 | "md" 284 | ] 285 | }, 286 | "text/mathml": { 287 | "extensions": [ 288 | "mml" 289 | ] 290 | }, 291 | "text/n3": { 292 | "extensions": [ 293 | "n3" 294 | ] 295 | }, 296 | "text/plain": { 297 | "extensions": [ 298 | "txt", 299 | "text", 300 | "conf", 301 | "def", 302 | "list", 303 | "log", 304 | "in", 305 | "ini" 306 | ] 307 | }, 308 | "text/prs.lines.tag": { 309 | "extensions": [ 310 | "dsc" 311 | ] 312 | }, 313 | "text/richtext": { 314 | "extensions": [ 315 | "rtx" 316 | ] 317 | }, 318 | "text/sgml": { 319 | "extensions": [ 320 | "sgml", 321 | "sgm" 322 | ] 323 | }, 324 | "text/shex": { 325 | "extensions": [ 326 | "shex" 327 | ] 328 | }, 329 | "text/slim": { 330 | "extensions": [ 331 | "slim", 332 | "slm" 333 | ] 334 | }, 335 | "text/stylus": { 336 | "extensions": [ 337 | "stylus", 338 | "styl" 339 | ] 340 | }, 341 | "text/troff": { 342 | "extensions": [ 343 | "t", 344 | "tr", 345 | "roff", 346 | "man", 347 | "me", 348 | "ms" 349 | ] 350 | }, 351 | "text/turtle": { 352 | "charset": "UTF-8", 353 | "extensions": [ 354 | "ttl" 355 | ] 356 | }, 357 | "text/uri-list": { 358 | "extensions": [ 359 | "uri", 360 | "uris", 361 | "urls" 362 | ] 363 | }, 364 | "text/vnd.curl": { 365 | "extensions": [ 366 | "curl" 367 | ] 368 | }, 369 | "text/vnd.curl.dcurl": { 370 | "extensions": [ 371 | "dcurl" 372 | ] 373 | }, 374 | "text/vnd.curl.mcurl": { 375 | "extensions": [ 376 | "mcurl" 377 | ] 378 | }, 379 | "text/vnd.curl.scurl": { 380 | "extensions": [ 381 | "scurl" 382 | ] 383 | }, 384 | "text/vnd.dvb.subtitle": { 385 | "extensions": [ 386 | "sub" 387 | ] 388 | }, 389 | "text/vnd.fly": { 390 | "extensions": [ 391 | "fly" 392 | ] 393 | }, 394 | "text/vnd.fmi.flexstor": { 395 | "extensions": [ 396 | "flx" 397 | ] 398 | }, 399 | "text/vnd.graphviz": { 400 | "extensions": [ 401 | "gv" 402 | ] 403 | }, 404 | "text/vnd.in3d.3dml": { 405 | "extensions": [ 406 | "3dml" 407 | ] 408 | }, 409 | "text/vnd.in3d.spot": { 410 | "extensions": [ 411 | "spot" 412 | ] 413 | }, 414 | "text/vnd.wap.wml": { 415 | "extensions": [ 416 | "wml" 417 | ] 418 | }, 419 | "text/vnd.wap.wmlscript": { 420 | "extensions": [ 421 | "wmls" 422 | ] 423 | }, 424 | "text/vtt": { 425 | "charset": "UTF-8", 426 | "extensions": [ 427 | "vtt" 428 | ] 429 | }, 430 | "text/x-asm": { 431 | "extensions": [ 432 | "s", 433 | "asm" 434 | ] 435 | }, 436 | "text/x-c": { 437 | "extensions": [ 438 | "c", 439 | "cc", 440 | "cxx", 441 | "cpp", 442 | "h", 443 | "hh", 444 | "dic" 445 | ] 446 | }, 447 | "text/x-component": { 448 | "extensions": [ 449 | "htc" 450 | ] 451 | }, 452 | "text/x-fortran": { 453 | "extensions": [ 454 | "f", 455 | "for", 456 | "f77", 457 | "f90" 458 | ] 459 | }, 460 | "text/x-handlebars-template": { 461 | "extensions": [ 462 | "hbs" 463 | ] 464 | }, 465 | "text/x-java-source": { 466 | "extensions": [ 467 | "java" 468 | ] 469 | }, 470 | "text/x-lua": { 471 | "extensions": [ 472 | "lua" 473 | ] 474 | }, 475 | "text/x-markdown": { 476 | "extensions": [ 477 | "mkd" 478 | ] 479 | }, 480 | "text/x-nfo": { 481 | "extensions": [ 482 | "nfo" 483 | ] 484 | }, 485 | "text/x-opml": { 486 | "extensions": [ 487 | "opml" 488 | ] 489 | }, 490 | "text/x-org": { 491 | "extensions": [ 492 | "org" 493 | ] 494 | }, 495 | "text/x-pascal": { 496 | "extensions": [ 497 | "p", 498 | "pas" 499 | ] 500 | }, 501 | "text/x-processing": { 502 | "extensions": [ 503 | "pde" 504 | ] 505 | }, 506 | "text/x-sass": { 507 | "extensions": [ 508 | "sass" 509 | ] 510 | }, 511 | "text/x-scss": { 512 | "extensions": [ 513 | "scss" 514 | ] 515 | }, 516 | "text/x-setext": { 517 | "extensions": [ 518 | "etx" 519 | ] 520 | }, 521 | "text/x-sfv": { 522 | "extensions": [ 523 | "sfv" 524 | ] 525 | }, 526 | "text/x-suse-ymp": { 527 | "extensions": [ 528 | "ymp" 529 | ] 530 | }, 531 | "text/x-uuencode": { 532 | "extensions": [ 533 | "uu" 534 | ] 535 | }, 536 | "text/xml": { 537 | "extensions": [ 538 | "xml" 539 | ] 540 | }, 541 | "text/yaml": { 542 | "extensions": [ 543 | "yaml", 544 | "yml" 545 | ] 546 | }, 547 | "video/mp4": { 548 | "extensions": [ 549 | "mp4", 550 | "mp4v", 551 | "mpg4" 552 | ] 553 | }, 554 | "video/webm": { 555 | "extensions": [ 556 | "webm" 557 | ] 558 | } 559 | } -------------------------------------------------------------------------------- /dist/index.js: -------------------------------------------------------------------------------- 1 | parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c1)for(var n=1;n=0;n--){var s=r[n];"."===s?r.splice(n,1):".."===s?(r.splice(n,1),e++):e&&(r.splice(n,1),e--)}if(t)for(;e--;e)r.unshift("..");return r}var e=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,n=function(r){return e.exec(r).slice(1)};function s(r,t){if(r.filter)return r.filter(t);for(var e=[],n=0;n=-1&&!n;o--){var i=o>=0?arguments[o]:r.cwd();if("string"!=typeof i)throw new TypeError("Arguments to path.resolve must be strings");i&&(e=i+"/"+e,n="/"===i.charAt(0))}return(n?"/":"")+(e=t(s(e.split("/"),function(r){return!!r}),!n).join("/"))||"."},exports.normalize=function(r){var e=exports.isAbsolute(r),n="/"===o(r,-1);return(r=t(s(r.split("/"),function(r){return!!r}),!e).join("/"))||e||(r="."),r&&n&&(r+="/"),(e?"/":"")+r},exports.isAbsolute=function(r){return"/"===r.charAt(0)},exports.join=function(){var r=Array.prototype.slice.call(arguments,0);return exports.normalize(s(r,function(r,t){if("string"!=typeof r)throw new TypeError("Arguments to path.join must be strings");return r}).join("/"))},exports.relative=function(r,t){function e(r){for(var t=0;t=0&&""===r[e];e--);return t>e?[]:r.slice(t,e-t+1)}r=exports.resolve(r).substr(1),t=exports.resolve(t).substr(1);for(var n=e(r.split("/")),s=e(t.split("/")),o=Math.min(n.length,s.length),i=o,u=0;uu||p===u&&"application/"===r[c].substr(0,12)))continue}r[c]=n}}})}exports.charset=n,exports.charsets={lookup:n},exports.contentType=o,exports.extension=i,exports.extensions=Object.create(null),exports.lookup=a,exports.types=Object.create(null),c(exports.extensions,exports.types); 11 | },{"mime-db":"ECDM","path":"UUq2"}]},{},["Focm"], null) 12 | //# sourceMappingURL=/index.js.map -------------------------------------------------------------------------------- /dist/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["../dist/browser-mime-db.json","../node_modules/process/browser.js","../node_modules/path-browserify/index.js","index.js"],"names":["module","exports","extensions","charset","cachedSetTimeout","cachedClearTimeout","process","defaultSetTimout","Error","defaultClearTimeout","runTimeout","fun","setTimeout","e","call","runClearTimeout","marker","clearTimeout","currentQueue","queue","draining","queueIndex","cleanUpNextTick","length","concat","drainQueue","timeout","len","run","Item","array","noop","nextTick","args","Array","arguments","i","push","prototype","apply","title","env","argv","version","versions","on","addListener","once","off","removeListener","removeAllListeners","emit","prependListener","prependOnceListener","listeners","name","binding","cwd","chdir","dir","umask","db","require","extname","EXTRACT_TYPE_REGEXP","TEXT_TYPE_REGEXP","type","match","exec","mime","toLowerCase","test","contentType","str","indexOf","lookup","extension","exts","path","substr","types","populateMaps","preference","undefined","Object","keys","forEach","from","source","to","charsets","create"],"mappings":";AAAAA,OAAOC,QAAQ,CAAyB,wBAAA,CAACC,WAAW,CAAC,QAAQ,MAAM,SAAqB,YAAA,CAACA,WAAW,CAAC,OAAO,MAAM,QAAQ,SAAsB,aAAA,CAACA,WAAW,CAAC,SAA4B,mBAAA,CAACA,WAAW,CAAC,SAAqB,YAAA,CAACA,WAAW,CAAC,QAAoB,YAAA,CAACA,WAAW,CAAC,QAAuB,eAAA,CAACA,WAAW,CAAC,SAAuB,cAAA,CAACA,WAAW,CAAC,QAAiC,yBAAA,CAACC,QAAQ,QAAQD,WAAW,CAAC,KAAK,QAAsB,cAAA,CAACA,WAAW,CAAC,QAAoB,YAAA,CAACA,WAAW,CAAC,MAAM,QAA+B,uBAAA,CAACA,WAAW,CAAC,SAA2B,kBAAA,CAACA,WAAW,CAAC,QAAqB,aAAA,CAACA,WAAW,CAAC,OAAO,MAAM,MAAM,MAAM,QAAqB,aAAA,CAACA,WAAW,CAAC,OAAO,MAAM,OAAO,MAAM,MAAM,QAAmB,WAAA,CAACA,WAAW,CAAC,QAAmB,WAAA,CAACA,WAAW,CAAC,QAAoB,YAAA,CAACA,WAAW,CAAC,SAAsB,aAAA,CAACA,WAAW,CAAC,UAAiC,uBAAA,CAACA,WAAW,CAAC,SAAkC,yBAAA,CAACA,WAAW,CAAC,OAAO,OAA8B,uBAAA,CAACA,WAAW,CAAC,YAA+B,mBAAA,CAACC,QAAQ,QAAQD,WAAW,CAAC,OAAO,QAAk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EAWX,SAASK,EAAc/E,EAAY8E,GAE7BE,IAAAA,EAAa,CAAC,QAAS,cAAUC,EAAW,QAEhDC,OAAOC,KAAKxB,GAAIyB,QAAQ,SAA0BpB,GAC5CG,IAAAA,EAAOR,EAAGK,GACVW,EAAOR,EAAKnE,WAEZ,GAAC2E,GAASA,EAAKtD,OAAf,CAKJrB,EAAWgE,GAAQW,EAGd,IAAA,IAAIzC,EAAI,EAAGA,EAAIyC,EAAKtD,OAAQa,IAAK,CAChCwC,IAAAA,EAAYC,EAAKzC,GAEjB4C,GAAAA,EAAMJ,GAAY,CAChBW,IAAAA,EAAOL,EAAWR,QAAQb,EAAGmB,EAAMJ,IAAYY,QAC/CC,EAAKP,EAAWR,QAAQL,EAAKmB,QAE7BR,GAAqB,6BAArBA,EAAMJ,KACPW,EAAOE,GAAOF,IAASE,GAAyC,iBAAnCT,EAAMJ,GAAWG,OAAO,EAAG,KAEzD,SAKJC,EAAMJ,GAAaV,MA1JzBjE,QAAQE,QAAUA,EAClBF,QAAQyF,SAAW,CAAEf,OAAQxE,GAC7BF,QAAQuE,YAAcA,EACtBvE,QAAQ2E,UAAYA,EACpB3E,QAAQC,WAAakF,OAAOO,OAAO,MACnC1F,QAAQ0E,OAASA,EACjB1E,QAAQ+E,MAAQI,OAAOO,OAAO,MAG9BV,EAAahF,QAAQC,WAAYD,QAAQ+E","file":"index.js","sourceRoot":"../mime-types","sourcesContent":["module.exports={\"application/xhtml+xml\":{extensions:[\"xhtml\",\"xht\",\"xhtm\"]},\"text/html\":{extensions:[\"html\",\"htm\",\"shtml\",\"shtm\"]},\"image/apng\":{extensions:[\"apng\"]},\"application/wasm\":{extensions:[\"wasm\"]},\"audio/mp3\":{extensions:[\"mp3\"]},\"audio/wav\":{extensions:[\"wav\"]},\"audio/x-flac\":{extensions:[\"flac\"]},\"audio/x-m4a\":{extensions:[\"m4a\"]},\"application/javascript\":{charset:\"UTF-8\",extensions:[\"js\",\"mjs\"]},\"video/x-m4v\":{extensions:[\"m4v\"]},\"video/ogg\":{extensions:[\"ogv\",\"ogm\"]},\"application/epub+zip\":{extensions:[\"epub\"]},\"application/pdf\":{extensions:[\"pdf\"]},\"video/mpeg\":{extensions:[\"mpeg\",\"mpg\",\"mpe\",\"m1v\",\"m2v\"]},\"audio/mpeg\":{extensions:[\"mpga\",\"mp2\",\"mp2a\",\"mp3\",\"m2a\",\"m3a\"]},\"font/otf\":{extensions:[\"otf\"]},\"font/ttf\":{extensions:[\"ttf\"]},\"font/woff\":{extensions:[\"woff\"]},\"font/woff2\":{extensions:[\"woff2\"]},\"application/atom+xml\":{extensions:[\"atom\"]},\"application/ecmascript\":{extensions:[\"ecma\",\"es\"]},\"application/geo+json\":{extensions:[\"geojson\"]},\"application/json\":{charset:\"UTF-8\",extensions:[\"json\",\"map\"]},\"application/jsonml+json\":{extensions:[\"jsonml\"]},\"application/ld+json\":{extensions:[\"jsonld\"]},\"application/manifest+json\":{charset:\"UTF-8\",extensions:[\"webmanifest\"]},\"application/ogg\":{extensions:[\"ogx\"]},\"application/rss+xml\":{extensions:[\"rss\"]},\"application/x-web-app-manifest+json\":{extensions:[\"webapp\"]},\"application/xml\":{extensions:[\"xml\",\"xsl\",\"xsd\",\"rng\"]},\"audio/mp4\":{extensions:[\"m4a\",\"mp4a\"]},\"audio/ogg\":{extensions:[\"oga\",\"ogg\",\"spx\"]},\"audio/webm\":{extensions:[\"weba\"]},\"audio/x-wav\":{extensions:[\"wav\"]},\"image/bmp\":{extensions:[\"bmp\"]},\"image/gif\":{extensions:[\"gif\"]},\"image/jpeg\":{extensions:[\"jpeg\",\"jpg\",\"jpe\"]},\"image/png\":{extensions:[\"png\"]},\"image/svg+xml\":{extensions:[\"svg\",\"svgz\"]},\"image/vnd.microsoft.icon\":{extensions:[\"ico\"]},\"image/webp\":{extensions:[\"webp\"]},\"image/x-icon\":{extensions:[\"ico\"]},\"image/x-xbitmap\":{extensions:[\"xbm\"]},\"text/cache-manifest\":{extensions:[\"appcache\",\"manifest\"]},\"text/coffeescript\":{extensions:[\"coffee\",\"litcoffee\"]},\"text/css\":{charset:\"UTF-8\",extensions:[\"css\"]},\"text/jade\":{extensions:[\"jade\"]},\"text/jsx\":{extensions:[\"jsx\"]},\"text/less\":{extensions:[\"less\"]},\"text/markdown\":{extensions:[\"markdown\",\"md\"]},\"text/mathml\":{extensions:[\"mml\"]},\"text/n3\":{extensions:[\"n3\"]},\"text/plain\":{extensions:[\"txt\",\"text\",\"conf\",\"def\",\"list\",\"log\",\"in\",\"ini\"]},\"text/prs.lines.tag\":{extensions:[\"dsc\"]},\"text/richtext\":{extensions:[\"rtx\"]},\"text/sgml\":{extensions:[\"sgml\",\"sgm\"]},\"text/shex\":{extensions:[\"shex\"]},\"text/slim\":{extensions:[\"slim\",\"slm\"]},\"text/stylus\":{extensions:[\"stylus\",\"styl\"]},\"text/troff\":{extensions:[\"t\",\"tr\",\"roff\",\"man\",\"me\",\"ms\"]},\"text/turtle\":{charset:\"UTF-8\",extensions:[\"ttl\"]},\"text/uri-list\":{extensions:[\"uri\",\"uris\",\"urls\"]},\"text/vnd.curl\":{extensions:[\"curl\"]},\"text/vnd.curl.dcurl\":{extensions:[\"dcurl\"]},\"text/vnd.curl.mcurl\":{extensions:[\"mcurl\"]},\"text/vnd.curl.scurl\":{extensions:[\"scurl\"]},\"text/vnd.dvb.subtitle\":{extensions:[\"sub\"]},\"text/vnd.fly\":{extensions:[\"fly\"]},\"text/vnd.fmi.flexstor\":{extensions:[\"flx\"]},\"text/vnd.graphviz\":{extensions:[\"gv\"]},\"text/vnd.in3d.3dml\":{extensions:[\"3dml\"]},\"text/vnd.in3d.spot\":{extensions:[\"spot\"]},\"text/vnd.wap.wml\":{extensions:[\"wml\"]},\"text/vnd.wap.wmlscript\":{extensions:[\"wmls\"]},\"text/vtt\":{charset:\"UTF-8\",extensions:[\"vtt\"]},\"text/x-asm\":{extensions:[\"s\",\"asm\"]},\"text/x-c\":{extensions:[\"c\",\"cc\",\"cxx\",\"cpp\",\"h\",\"hh\",\"dic\"]},\"text/x-component\":{extensions:[\"htc\"]},\"text/x-fortran\":{extensions:[\"f\",\"for\",\"f77\",\"f90\"]},\"text/x-handlebars-template\":{extensions:[\"hbs\"]},\"text/x-java-source\":{extensions:[\"java\"]},\"text/x-lua\":{extensions:[\"lua\"]},\"text/x-markdown\":{extensions:[\"mkd\"]},\"text/x-nfo\":{extensions:[\"nfo\"]},\"text/x-opml\":{extensions:[\"opml\"]},\"text/x-org\":{extensions:[\"org\"]},\"text/x-pascal\":{extensions:[\"p\",\"pas\"]},\"text/x-processing\":{extensions:[\"pde\"]},\"text/x-sass\":{extensions:[\"sass\"]},\"text/x-scss\":{extensions:[\"scss\"]},\"text/x-setext\":{extensions:[\"etx\"]},\"text/x-sfv\":{extensions:[\"sfv\"]},\"text/x-suse-ymp\":{extensions:[\"ymp\"]},\"text/x-uuencode\":{extensions:[\"uu\"]},\"text/xml\":{extensions:[\"xml\"]},\"text/yaml\":{extensions:[\"yaml\",\"yml\"]},\"video/mp4\":{extensions:[\"mp4\",\"mp4v\",\"mpg4\"]},\"video/webm\":{extensions:[\"webm\"]}};","// shim for using process in browser\nvar process = module.exports = {};\n\n// cached from whatever global is present so that test runners that stub it\n// don't break things. But we need to wrap it in a try catch in case it is\n// wrapped in strict mode code which doesn't define any globals. It's inside a\n// function because try/catches deoptimize in certain engines.\n\nvar cachedSetTimeout;\nvar cachedClearTimeout;\n\nfunction defaultSetTimout() {\n throw new Error('setTimeout has not been defined');\n}\nfunction defaultClearTimeout () {\n throw new Error('clearTimeout has not been defined');\n}\n(function () {\n try {\n if (typeof setTimeout === 'function') {\n cachedSetTimeout = setTimeout;\n } else {\n cachedSetTimeout = defaultSetTimout;\n }\n } catch (e) {\n cachedSetTimeout = defaultSetTimout;\n }\n try {\n if (typeof clearTimeout === 'function') {\n cachedClearTimeout = clearTimeout;\n } else {\n cachedClearTimeout = defaultClearTimeout;\n }\n } catch (e) {\n cachedClearTimeout = defaultClearTimeout;\n }\n} ())\nfunction runTimeout(fun) {\n if (cachedSetTimeout === setTimeout) {\n //normal enviroments in sane situations\n return setTimeout(fun, 0);\n }\n // if setTimeout wasn't available but was latter defined\n if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {\n cachedSetTimeout = setTimeout;\n return setTimeout(fun, 0);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedSetTimeout(fun, 0);\n } catch(e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedSetTimeout.call(null, fun, 0);\n } catch(e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error\n return cachedSetTimeout.call(this, fun, 0);\n }\n }\n\n\n}\nfunction runClearTimeout(marker) {\n if (cachedClearTimeout === clearTimeout) {\n //normal enviroments in sane situations\n return clearTimeout(marker);\n }\n // if clearTimeout wasn't available but was latter defined\n if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {\n cachedClearTimeout = clearTimeout;\n return clearTimeout(marker);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedClearTimeout(marker);\n } catch (e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedClearTimeout.call(null, marker);\n } catch (e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.\n // Some versions of I.E. have different rules for clearTimeout vs setTimeout\n return cachedClearTimeout.call(this, marker);\n }\n }\n\n\n\n}\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n if (!draining || !currentQueue) {\n return;\n }\n draining = false;\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n var timeout = runTimeout(cleanUpNextTick);\n draining = true;\n\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n while (++queueIndex < len) {\n if (currentQueue) {\n currentQueue[queueIndex].run();\n }\n }\n queueIndex = -1;\n len = queue.length;\n }\n currentQueue = null;\n draining = false;\n runClearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n var args = new Array(arguments.length - 1);\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n queue.push(new Item(fun, args));\n if (queue.length === 1 && !draining) {\n runTimeout(drainQueue);\n }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\nprocess.prependListener = noop;\nprocess.prependOnceListener = noop;\n\nprocess.listeners = function (name) { return [] }\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// resolves . and .. elements in a path array with directory names there\n// must be no slashes, empty elements, or device names (c:\\) in the array\n// (so also no leading and trailing slashes - it does not distinguish\n// relative and absolute paths)\nfunction normalizeArray(parts, allowAboveRoot) {\n // if the path tries to go above the root, `up` ends up > 0\n var up = 0;\n for (var i = parts.length - 1; i >= 0; i--) {\n var last = parts[i];\n if (last === '.') {\n parts.splice(i, 1);\n } else if (last === '..') {\n parts.splice(i, 1);\n up++;\n } else if (up) {\n parts.splice(i, 1);\n up--;\n }\n }\n\n // if the path is allowed to go above the root, restore leading ..s\n if (allowAboveRoot) {\n for (; up--; up) {\n parts.unshift('..');\n }\n }\n\n return parts;\n}\n\n// Split a filename into [root, dir, basename, ext], unix version\n// 'root' is just a slash, or nothing.\nvar splitPathRe =\n /^(\\/?|)([\\s\\S]*?)((?:\\.{1,2}|[^\\/]+?|)(\\.[^.\\/]*|))(?:[\\/]*)$/;\nvar splitPath = function(filename) {\n return splitPathRe.exec(filename).slice(1);\n};\n\n// path.resolve([from ...], to)\n// posix version\nexports.resolve = function() {\n var resolvedPath = '',\n resolvedAbsolute = false;\n\n for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {\n var path = (i >= 0) ? arguments[i] : process.cwd();\n\n // Skip empty and invalid entries\n if (typeof path !== 'string') {\n throw new TypeError('Arguments to path.resolve must be strings');\n } else if (!path) {\n continue;\n }\n\n resolvedPath = path + '/' + resolvedPath;\n resolvedAbsolute = path.charAt(0) === '/';\n }\n\n // At this point the path should be resolved to a full absolute path, but\n // handle relative paths to be safe (might happen when process.cwd() fails)\n\n // Normalize the path\n resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {\n return !!p;\n }), !resolvedAbsolute).join('/');\n\n return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';\n};\n\n// path.normalize(path)\n// posix version\nexports.normalize = function(path) {\n var isAbsolute = exports.isAbsolute(path),\n trailingSlash = substr(path, -1) === '/';\n\n // Normalize the path\n path = normalizeArray(filter(path.split('/'), function(p) {\n return !!p;\n }), !isAbsolute).join('/');\n\n if (!path && !isAbsolute) {\n path = '.';\n }\n if (path && trailingSlash) {\n path += '/';\n }\n\n return (isAbsolute ? '/' : '') + path;\n};\n\n// posix version\nexports.isAbsolute = function(path) {\n return path.charAt(0) === '/';\n};\n\n// posix version\nexports.join = function() {\n var paths = Array.prototype.slice.call(arguments, 0);\n return exports.normalize(filter(paths, function(p, index) {\n if (typeof p !== 'string') {\n throw new TypeError('Arguments to path.join must be strings');\n }\n return p;\n }).join('/'));\n};\n\n\n// path.relative(from, to)\n// posix version\nexports.relative = function(from, to) {\n from = exports.resolve(from).substr(1);\n to = exports.resolve(to).substr(1);\n\n function trim(arr) {\n var start = 0;\n for (; start < arr.length; start++) {\n if (arr[start] !== '') break;\n }\n\n var end = arr.length - 1;\n for (; end >= 0; end--) {\n if (arr[end] !== '') break;\n }\n\n if (start > end) return [];\n return arr.slice(start, end - start + 1);\n }\n\n var fromParts = trim(from.split('/'));\n var toParts = trim(to.split('/'));\n\n var length = Math.min(fromParts.length, toParts.length);\n var samePartsLength = length;\n for (var i = 0; i < length; i++) {\n if (fromParts[i] !== toParts[i]) {\n samePartsLength = i;\n break;\n }\n }\n\n var outputParts = [];\n for (var i = samePartsLength; i < fromParts.length; i++) {\n outputParts.push('..');\n }\n\n outputParts = outputParts.concat(toParts.slice(samePartsLength));\n\n return outputParts.join('/');\n};\n\nexports.sep = '/';\nexports.delimiter = ':';\n\nexports.dirname = function(path) {\n var result = splitPath(path),\n root = result[0],\n dir = result[1];\n\n if (!root && !dir) {\n // No dirname whatsoever\n return '.';\n }\n\n if (dir) {\n // It has a dirname, strip trailing slash\n dir = dir.substr(0, dir.length - 1);\n }\n\n return root + dir;\n};\n\n\nexports.basename = function(path, ext) {\n var f = splitPath(path)[2];\n // TODO: make this comparison case-insensitive on windows?\n if (ext && f.substr(-1 * ext.length) === ext) {\n f = f.substr(0, f.length - ext.length);\n }\n return f;\n};\n\n\nexports.extname = function(path) {\n return splitPath(path)[3];\n};\n\nfunction filter (xs, f) {\n if (xs.filter) return xs.filter(f);\n var res = [];\n for (var i = 0; i < xs.length; i++) {\n if (f(xs[i], i, xs)) res.push(xs[i]);\n }\n return res;\n}\n\n// String.prototype.substr - negative index don't work in IE8\nvar substr = 'ab'.substr(-1) === 'b'\n ? function (str, start, len) { return str.substr(start, len) }\n : function (str, start, len) {\n if (start < 0) start = str.length + start;\n return str.substr(start, len);\n }\n;\n","/*!\n * mime-types\n * Copyright(c) 2014 Jonathan Ong\n * Copyright(c) 2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict'\n\n/**\n * Module dependencies.\n * @private\n */\n\nvar db = require('mime-db')\nvar extname = require('path').extname\n\n/**\n * Module variables.\n * @private\n */\n\nvar EXTRACT_TYPE_REGEXP = /^\\s*([^;\\s]*)(?:;|\\s|$)/\nvar TEXT_TYPE_REGEXP = /^text\\//i\n\n/**\n * Module exports.\n * @public\n */\n\nexports.charset = charset\nexports.charsets = { lookup: charset }\nexports.contentType = contentType\nexports.extension = extension\nexports.extensions = Object.create(null)\nexports.lookup = lookup\nexports.types = Object.create(null)\n\n// Populate the extensions/types maps\npopulateMaps(exports.extensions, exports.types)\n\n/**\n * Get the default charset for a MIME type.\n *\n * @param {string} type\n * @return {boolean|string}\n */\n\nfunction charset (type) {\n if (!type || typeof type !== 'string') {\n return false\n }\n\n // TODO: use media-typer\n var match = EXTRACT_TYPE_REGEXP.exec(type)\n var mime = match && db[match[1].toLowerCase()]\n\n if (mime && mime.charset) {\n return mime.charset\n }\n\n // default text/* to utf-8\n if (match && TEXT_TYPE_REGEXP.test(match[1])) {\n return 'UTF-8'\n }\n\n return false\n}\n\n/**\n * Create a full Content-Type header given a MIME type or extension.\n *\n * @param {string} str\n * @return {boolean|string}\n */\n\nfunction contentType (str) {\n // TODO: should this even be in this module?\n if (!str || typeof str !== 'string') {\n return false\n }\n\n var mime = str.indexOf('/') === -1\n ? exports.lookup(str)\n : str\n\n if (!mime) {\n return false\n }\n\n // TODO: use content-type or other module\n if (mime.indexOf('charset') === -1) {\n var charset = exports.charset(mime)\n if (charset) mime += '; charset=' + charset.toLowerCase()\n }\n\n return mime\n}\n\n/**\n * Get the default extension for a MIME type.\n *\n * @param {string} type\n * @return {boolean|string}\n */\n\nfunction extension (type) {\n if (!type || typeof type !== 'string') {\n return false\n }\n\n // TODO: use media-typer\n var match = EXTRACT_TYPE_REGEXP.exec(type)\n\n // get extensions\n var exts = match && exports.extensions[match[1].toLowerCase()]\n\n if (!exts || !exts.length) {\n return false\n }\n\n return exts[0]\n}\n\n/**\n * Lookup the MIME type for a file path/extension.\n *\n * @param {string} path\n * @return {boolean|string}\n */\n\nfunction lookup (path) {\n if (!path || typeof path !== 'string') {\n return false\n }\n\n // get the extension (\"ext\" or \".ext\" or full path)\n var extension = extname('x.' + path)\n .toLowerCase()\n .substr(1)\n\n if (!extension) {\n return false\n }\n\n return exports.types[extension] || false\n}\n\n/**\n * Populate the extensions and types maps.\n * @private\n */\n\nfunction populateMaps (extensions, types) {\n // source preference (least -> most)\n var preference = ['nginx', 'apache', undefined, 'iana']\n\n Object.keys(db).forEach(function forEachMimeType (type) {\n var mime = db[type]\n var exts = mime.extensions\n\n if (!exts || !exts.length) {\n return\n }\n\n // mime -> extensions\n extensions[type] = exts\n\n // extension -> mime\n for (var i = 0; i < exts.length; i++) {\n var extension = exts[i]\n\n if (types[extension]) {\n var from = preference.indexOf(db[types[extension]].source)\n var to = preference.indexOf(mime.source)\n\n if (types[extension] !== 'application/octet-stream' &&\n (from > to || (from === to && types[extension].substr(0, 12) === 'application/'))) {\n // skip the remapping\n continue\n }\n }\n\n // set the extension -> mime\n types[extension] = type\n }\n })\n}\n"]} -------------------------------------------------------------------------------- /env.sample: -------------------------------------------------------------------------------- 1 | ### 2 | # Dev ENVIRONMENT file 3 | # 4 | # Copy to .env to use defaults when releasing via `npm release` 5 | ### 6 | 7 | # GitHub Personal Access Token (to push releases) 8 | # https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/ 9 | GITHUB_TOKEN= 10 | -------------------------------------------------------------------------------- /mime-types/.eslintignore: -------------------------------------------------------------------------------- 1 | coverage 2 | node_modules 3 | -------------------------------------------------------------------------------- /mime-types/.eslintrc.yml: -------------------------------------------------------------------------------- 1 | root: true 2 | extends: standard 3 | -------------------------------------------------------------------------------- /mime-types/.gitignore: -------------------------------------------------------------------------------- 1 | .nyc_output 2 | coverage 3 | node_modules 4 | npm-debug.log 5 | package-lock.json 6 | -------------------------------------------------------------------------------- /mime-types/.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "0.6" 4 | - "0.8" 5 | - "0.10" 6 | - "0.12" 7 | - "1.8" 8 | - "2.5" 9 | - "3.3" 10 | - "4.9" 11 | - "5.12" 12 | - "6.16" 13 | - "7.10" 14 | - "8.15" 15 | - "9.11" 16 | - "10.15" 17 | - "11.9" 18 | sudo: false 19 | dist: trusty 20 | env: 21 | global: 22 | # Suppress Node.js 0.6 compile warnings 23 | - "CXXCOM='$CXX -o $TARGET -c $CXXFLAGS $CCFLAGS -Wno-unused-local-typedefs -Wno-maybe-uninitialized -Wno-narrowing -Wno-strict-overflow $_CCCOMCOM $SOURCES'" 24 | cache: 25 | directories: 26 | - node_modules 27 | before_install: 28 | # Configure npm 29 | - | 30 | # Skip updating shrinkwrap / lock 31 | npm config set shrinkwrap false 32 | # Setup Node.js version-specific dependencies 33 | - | 34 | # mocha for testing 35 | # - use 1.x for Node.js < 0.8 36 | # - use 2.x for Node.js < 0.10 37 | # - use 3.x for Node.js < 6 38 | if [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -eq 0 && "$(cut -d. -f2 <<< "$TRAVIS_NODE_VERSION")" -lt 8 ]]; then 39 | npm install --save-dev mocha@1.21.5 40 | elif [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -eq 0 && "$(cut -d. -f2 <<< "$TRAVIS_NODE_VERSION")" -lt 10 ]]; then 41 | npm install --save-dev mocha@2.5.3 42 | elif [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -lt 6 ]]; then 43 | npm install --save-dev mocha@3.5.3 44 | fi 45 | - | 46 | # nyc for coverage 47 | # - remove for Node.js < 0.10 48 | # - use 10.x for Node.js < 4 49 | # - use 11.x for Node.js < 6 50 | if [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -eq 0 && "$(cut -d. -f2 <<< "$TRAVIS_NODE_VERSION")" -lt 10 ]]; then 51 | npm rm --save-dev nyc 52 | elif [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -lt 4 ]]; then 53 | npm install --save-dev nyc@10.3.2 54 | elif [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -lt 6 ]]; then 55 | npm install --save-dev nyc@11.9.0 56 | fi 57 | - | 58 | # eslint for linting 59 | # - remove on Node.js < 6 60 | if [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -lt 6 ]]; then 61 | node -pe 'Object.keys(require("./package").devDependencies).join("\n")' | \ 62 | grep -E '^eslint(-|$)' | \ 63 | xargs npm rm --save-dev 64 | fi 65 | # Update Node.js modules 66 | - | 67 | # Prune & rebuild node_modules 68 | if [[ -d node_modules ]]; then 69 | npm prune 70 | npm rebuild 71 | fi 72 | script: 73 | - | 74 | # Run test script, depending on istanbul install 75 | if [[ -z "$(npm -ps ls istanbul)" ]]; then 76 | npm test 77 | else 78 | npm run-script test-travis 79 | fi 80 | - | 81 | # Run linting, if eslint exists 82 | if [[ -n "$(npm -ps ls eslint)" ]]; then 83 | npm run-script lint 84 | fi 85 | after_script: 86 | - | 87 | # Upload coverage to coveralls if exists 88 | if [[ -d .nyc_output ]]; then 89 | npm install --save-dev coveralls@2 90 | nyc report --reporter=text-lcov | coveralls 91 | fi 92 | -------------------------------------------------------------------------------- /mime-types/HISTORY.md: -------------------------------------------------------------------------------- 1 | 2.1.22 / 2019-02-14 2 | =================== 3 | 4 | * deps: mime-db@~1.38.0 5 | - Add extension `.nq` to `application/n-quads` 6 | - Add extension `.nt` to `application/n-triples` 7 | - Add new upstream MIME types 8 | - Mark `text/less` as compressible 9 | 10 | 2.1.21 / 2018-10-19 11 | =================== 12 | 13 | * deps: mime-db@~1.37.0 14 | - Add extensions to HEIC image types 15 | - Add new upstream MIME types 16 | 17 | 2.1.20 / 2018-08-26 18 | =================== 19 | 20 | * deps: mime-db@~1.36.0 21 | - Add Apple file extensions from IANA 22 | - Add extensions from IANA for `image/*` types 23 | - Add new upstream MIME types 24 | 25 | 2.1.19 / 2018-07-17 26 | =================== 27 | 28 | * deps: mime-db@~1.35.0 29 | - Add extension `.csl` to `application/vnd.citationstyles.style+xml` 30 | - Add extension `.es` to `application/ecmascript` 31 | - Add extension `.owl` to `application/rdf+xml` 32 | - Add new upstream MIME types 33 | - Add UTF-8 as default charset for `text/turtle` 34 | 35 | 2.1.18 / 2018-02-16 36 | =================== 37 | 38 | * deps: mime-db@~1.33.0 39 | - Add `application/raml+yaml` with extension `.raml` 40 | - Add `application/wasm` with extension `.wasm` 41 | - Add `text/shex` with extension `.shex` 42 | - Add extensions for JPEG-2000 images 43 | - Add extensions from IANA for `message/*` types 44 | - Add new upstream MIME types 45 | - Update font MIME types 46 | - Update `text/hjson` to registered `application/hjson` 47 | 48 | 2.1.17 / 2017-09-01 49 | =================== 50 | 51 | * deps: mime-db@~1.30.0 52 | - Add `application/vnd.ms-outlook` 53 | - Add `application/x-arj` 54 | - Add extension `.mjs` to `application/javascript` 55 | - Add glTF types and extensions 56 | - Add new upstream MIME types 57 | - Add `text/x-org` 58 | - Add VirtualBox MIME types 59 | - Fix `source` records for `video/*` types that are IANA 60 | - Update `font/opentype` to registered `font/otf` 61 | 62 | 2.1.16 / 2017-07-24 63 | =================== 64 | 65 | * deps: mime-db@~1.29.0 66 | - Add `application/fido.trusted-apps+json` 67 | - Add extension `.wadl` to `application/vnd.sun.wadl+xml` 68 | - Add extension `.gz` to `application/gzip` 69 | - Add new upstream MIME types 70 | - Update extensions `.md` and `.markdown` to be `text/markdown` 71 | 72 | 2.1.15 / 2017-03-23 73 | =================== 74 | 75 | * deps: mime-db@~1.27.0 76 | - Add new mime types 77 | - Add `image/apng` 78 | 79 | 2.1.14 / 2017-01-14 80 | =================== 81 | 82 | * deps: mime-db@~1.26.0 83 | - Add new mime types 84 | 85 | 2.1.13 / 2016-11-18 86 | =================== 87 | 88 | * deps: mime-db@~1.25.0 89 | - Add new mime types 90 | 91 | 2.1.12 / 2016-09-18 92 | =================== 93 | 94 | * deps: mime-db@~1.24.0 95 | - Add new mime types 96 | - Add `audio/mp3` 97 | 98 | 2.1.11 / 2016-05-01 99 | =================== 100 | 101 | * deps: mime-db@~1.23.0 102 | - Add new mime types 103 | 104 | 2.1.10 / 2016-02-15 105 | =================== 106 | 107 | * deps: mime-db@~1.22.0 108 | - Add new mime types 109 | - Fix extension of `application/dash+xml` 110 | - Update primary extension for `audio/mp4` 111 | 112 | 2.1.9 / 2016-01-06 113 | ================== 114 | 115 | * deps: mime-db@~1.21.0 116 | - Add new mime types 117 | 118 | 2.1.8 / 2015-11-30 119 | ================== 120 | 121 | * deps: mime-db@~1.20.0 122 | - Add new mime types 123 | 124 | 2.1.7 / 2015-09-20 125 | ================== 126 | 127 | * deps: mime-db@~1.19.0 128 | - Add new mime types 129 | 130 | 2.1.6 / 2015-09-03 131 | ================== 132 | 133 | * deps: mime-db@~1.18.0 134 | - Add new mime types 135 | 136 | 2.1.5 / 2015-08-20 137 | ================== 138 | 139 | * deps: mime-db@~1.17.0 140 | - Add new mime types 141 | 142 | 2.1.4 / 2015-07-30 143 | ================== 144 | 145 | * deps: mime-db@~1.16.0 146 | - Add new mime types 147 | 148 | 2.1.3 / 2015-07-13 149 | ================== 150 | 151 | * deps: mime-db@~1.15.0 152 | - Add new mime types 153 | 154 | 2.1.2 / 2015-06-25 155 | ================== 156 | 157 | * deps: mime-db@~1.14.0 158 | - Add new mime types 159 | 160 | 2.1.1 / 2015-06-08 161 | ================== 162 | 163 | * perf: fix deopt during mapping 164 | 165 | 2.1.0 / 2015-06-07 166 | ================== 167 | 168 | * Fix incorrectly treating extension-less file name as extension 169 | - i.e. `'path/to/json'` will no longer return `application/json` 170 | * Fix `.charset(type)` to accept parameters 171 | * Fix `.charset(type)` to match case-insensitive 172 | * Improve generation of extension to MIME mapping 173 | * Refactor internals for readability and no argument reassignment 174 | * Prefer `application/*` MIME types from the same source 175 | * Prefer any type over `application/octet-stream` 176 | * deps: mime-db@~1.13.0 177 | - Add nginx as a source 178 | - Add new mime types 179 | 180 | 2.0.14 / 2015-06-06 181 | =================== 182 | 183 | * deps: mime-db@~1.12.0 184 | - Add new mime types 185 | 186 | 2.0.13 / 2015-05-31 187 | =================== 188 | 189 | * deps: mime-db@~1.11.0 190 | - Add new mime types 191 | 192 | 2.0.12 / 2015-05-19 193 | =================== 194 | 195 | * deps: mime-db@~1.10.0 196 | - Add new mime types 197 | 198 | 2.0.11 / 2015-05-05 199 | =================== 200 | 201 | * deps: mime-db@~1.9.1 202 | - Add new mime types 203 | 204 | 2.0.10 / 2015-03-13 205 | =================== 206 | 207 | * deps: mime-db@~1.8.0 208 | - Add new mime types 209 | 210 | 2.0.9 / 2015-02-09 211 | ================== 212 | 213 | * deps: mime-db@~1.7.0 214 | - Add new mime types 215 | - Community extensions ownership transferred from `node-mime` 216 | 217 | 2.0.8 / 2015-01-29 218 | ================== 219 | 220 | * deps: mime-db@~1.6.0 221 | - Add new mime types 222 | 223 | 2.0.7 / 2014-12-30 224 | ================== 225 | 226 | * deps: mime-db@~1.5.0 227 | - Add new mime types 228 | - Fix various invalid MIME type entries 229 | 230 | 2.0.6 / 2014-12-30 231 | ================== 232 | 233 | * deps: mime-db@~1.4.0 234 | - Add new mime types 235 | - Fix various invalid MIME type entries 236 | - Remove example template MIME types 237 | 238 | 2.0.5 / 2014-12-29 239 | ================== 240 | 241 | * deps: mime-db@~1.3.1 242 | - Fix missing extensions 243 | 244 | 2.0.4 / 2014-12-10 245 | ================== 246 | 247 | * deps: mime-db@~1.3.0 248 | - Add new mime types 249 | 250 | 2.0.3 / 2014-11-09 251 | ================== 252 | 253 | * deps: mime-db@~1.2.0 254 | - Add new mime types 255 | 256 | 2.0.2 / 2014-09-28 257 | ================== 258 | 259 | * deps: mime-db@~1.1.0 260 | - Add new mime types 261 | - Add additional compressible 262 | - Update charsets 263 | 264 | 2.0.1 / 2014-09-07 265 | ================== 266 | 267 | * Support Node.js 0.6 268 | 269 | 2.0.0 / 2014-09-02 270 | ================== 271 | 272 | * Use `mime-db` 273 | * Remove `.define()` 274 | 275 | 1.0.2 / 2014-08-04 276 | ================== 277 | 278 | * Set charset=utf-8 for `text/javascript` 279 | 280 | 1.0.1 / 2014-06-24 281 | ================== 282 | 283 | * Add `text/jsx` type 284 | 285 | 1.0.0 / 2014-05-12 286 | ================== 287 | 288 | * Return `false` for unknown types 289 | * Set charset=utf-8 for `application/json` 290 | 291 | 0.1.0 / 2014-05-02 292 | ================== 293 | 294 | * Initial release 295 | -------------------------------------------------------------------------------- /mime-types/LICENSE: -------------------------------------------------------------------------------- 1 | (The MIT License) 2 | 3 | Copyright (c) 2014 Jonathan Ong 4 | Copyright (c) 2015 Douglas Christopher Wilson 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | 'Software'), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /mime-types/README.md: -------------------------------------------------------------------------------- 1 | # mime-types 2 | 3 | [![NPM Version][npm-version-image]][npm-url] 4 | [![NPM Downloads][npm-downloads-image]][npm-url] 5 | [![Node.js Version][node-version-image]][node-version-url] 6 | [![Build Status][travis-image]][travis-url] 7 | [![Test Coverage][coveralls-image]][coveralls-url] 8 | 9 | The ultimate javascript content-type utility. 10 | 11 | Similar to [the `mime@1.x` module](https://www.npmjs.com/package/mime), except: 12 | 13 | - __No fallbacks.__ Instead of naively returning the first available type, 14 | `mime-types` simply returns `false`, so do 15 | `var type = mime.lookup('unrecognized') || 'application/octet-stream'`. 16 | - No `new Mime()` business, so you could do `var lookup = require('mime-types').lookup`. 17 | - No `.define()` functionality 18 | - Bug fixes for `.lookup(path)` 19 | 20 | Otherwise, the API is compatible with `mime` 1.x. 21 | 22 | ## Install 23 | 24 | This is a [Node.js](https://nodejs.org/en/) module available through the 25 | [npm registry](https://www.npmjs.com/). Installation is done using the 26 | [`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally): 27 | 28 | ```sh 29 | $ npm install mime-types 30 | ``` 31 | 32 | ## Adding Types 33 | 34 | All mime types are based on [mime-db](https://www.npmjs.com/package/mime-db), 35 | so open a PR there if you'd like to add mime types. 36 | 37 | ## API 38 | 39 | ```js 40 | var mime = require('mime-types') 41 | ``` 42 | 43 | All functions return `false` if input is invalid or not found. 44 | 45 | ### mime.lookup(path) 46 | 47 | Lookup the content-type associated with a file. 48 | 49 | ```js 50 | mime.lookup('json') // 'application/json' 51 | mime.lookup('.md') // 'text/markdown' 52 | mime.lookup('file.html') // 'text/html' 53 | mime.lookup('folder/file.js') // 'application/javascript' 54 | mime.lookup('folder/.htaccess') // false 55 | 56 | mime.lookup('cats') // false 57 | ``` 58 | 59 | ### mime.contentType(type) 60 | 61 | Create a full content-type header given a content-type or extension. 62 | When given an extension, `mime.lookup` is used to get the matching 63 | content-type, otherwise the given content-type is used. Then if the 64 | content-type does not already have a `charset` parameter, `mime.charset` 65 | is used to get the default charset and add to the returned content-type. 66 | 67 | ```js 68 | mime.contentType('markdown') // 'text/x-markdown; charset=utf-8' 69 | mime.contentType('file.json') // 'application/json; charset=utf-8' 70 | mime.contentType('text/html') // 'text/html; charset=utf-8' 71 | mime.contentType('text/html; charset=iso-8859-1') // 'text/html; charset=iso-8859-1' 72 | 73 | // from a full path 74 | mime.contentType(path.extname('/path/to/file.json')) // 'application/json; charset=utf-8' 75 | ``` 76 | 77 | ### mime.extension(type) 78 | 79 | Get the default extension for a content-type. 80 | 81 | ```js 82 | mime.extension('application/octet-stream') // 'bin' 83 | ``` 84 | 85 | ### mime.charset(type) 86 | 87 | Lookup the implied default charset of a content-type. 88 | 89 | ```js 90 | mime.charset('text/markdown') // 'UTF-8' 91 | ``` 92 | 93 | ### var type = mime.types[extension] 94 | 95 | A map of content-types by extension. 96 | 97 | ### [extensions...] = mime.extensions[type] 98 | 99 | A map of extensions by content-type. 100 | 101 | ## License 102 | 103 | [MIT](LICENSE) 104 | 105 | [coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/mime-types/master 106 | [coveralls-url]: https://coveralls.io/r/jshttp/mime-types?branch=master 107 | [node-version-image]: https://badgen.net/npm/node/mime-types 108 | [node-version-url]: https://nodejs.org/en/download 109 | [npm-downloads-image]: https://badgen.net/npm/dm/mime-types 110 | [npm-url]: https://npmjs.org/package/mime-types 111 | [npm-version-image]: https://badgen.net/npm/v/mime-types 112 | [travis-image]: https://badgen.net/travis/jshttp/mime-types/master 113 | [travis-url]: https://travis-ci.org/jshttp/mime-types 114 | -------------------------------------------------------------------------------- /mime-types/index.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * mime-types 3 | * Copyright(c) 2014 Jonathan Ong 4 | * Copyright(c) 2015 Douglas Christopher Wilson 5 | * MIT Licensed 6 | */ 7 | 8 | 'use strict' 9 | 10 | /** 11 | * Module dependencies. 12 | * @private 13 | */ 14 | 15 | var db = require('mime-db') 16 | var extname = require('path').extname 17 | 18 | /** 19 | * Module variables. 20 | * @private 21 | */ 22 | 23 | var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/ 24 | var TEXT_TYPE_REGEXP = /^text\//i 25 | 26 | /** 27 | * Module exports. 28 | * @public 29 | */ 30 | 31 | exports.charset = charset 32 | exports.charsets = { lookup: charset } 33 | exports.contentType = contentType 34 | exports.extension = extension 35 | exports.extensions = Object.create(null) 36 | exports.lookup = lookup 37 | exports.types = Object.create(null) 38 | 39 | // Populate the extensions/types maps 40 | populateMaps(exports.extensions, exports.types) 41 | 42 | /** 43 | * Get the default charset for a MIME type. 44 | * 45 | * @param {string} type 46 | * @return {boolean|string} 47 | */ 48 | 49 | function charset (type) { 50 | if (!type || typeof type !== 'string') { 51 | return false 52 | } 53 | 54 | // TODO: use media-typer 55 | var match = EXTRACT_TYPE_REGEXP.exec(type) 56 | var mime = match && db[match[1].toLowerCase()] 57 | 58 | if (mime && mime.charset) { 59 | return mime.charset 60 | } 61 | 62 | // default text/* to utf-8 63 | if (match && TEXT_TYPE_REGEXP.test(match[1])) { 64 | return 'UTF-8' 65 | } 66 | 67 | return false 68 | } 69 | 70 | /** 71 | * Create a full Content-Type header given a MIME type or extension. 72 | * 73 | * @param {string} str 74 | * @return {boolean|string} 75 | */ 76 | 77 | function contentType (str) { 78 | // TODO: should this even be in this module? 79 | if (!str || typeof str !== 'string') { 80 | return false 81 | } 82 | 83 | var mime = str.indexOf('/') === -1 84 | ? exports.lookup(str) 85 | : str 86 | 87 | if (!mime) { 88 | return false 89 | } 90 | 91 | // TODO: use content-type or other module 92 | if (mime.indexOf('charset') === -1) { 93 | var charset = exports.charset(mime) 94 | if (charset) mime += '; charset=' + charset.toLowerCase() 95 | } 96 | 97 | return mime 98 | } 99 | 100 | /** 101 | * Get the default extension for a MIME type. 102 | * 103 | * @param {string} type 104 | * @return {boolean|string} 105 | */ 106 | 107 | function extension (type) { 108 | if (!type || typeof type !== 'string') { 109 | return false 110 | } 111 | 112 | // TODO: use media-typer 113 | var match = EXTRACT_TYPE_REGEXP.exec(type) 114 | 115 | // get extensions 116 | var exts = match && exports.extensions[match[1].toLowerCase()] 117 | 118 | if (!exts || !exts.length) { 119 | return false 120 | } 121 | 122 | return exts[0] 123 | } 124 | 125 | /** 126 | * Lookup the MIME type for a file path/extension. 127 | * 128 | * @param {string} path 129 | * @return {boolean|string} 130 | */ 131 | 132 | function lookup (path) { 133 | if (!path || typeof path !== 'string') { 134 | return false 135 | } 136 | 137 | // get the extension ("ext" or ".ext" or full path) 138 | var extension = extname('x.' + path) 139 | .toLowerCase() 140 | .substr(1) 141 | 142 | if (!extension) { 143 | return false 144 | } 145 | 146 | return exports.types[extension] || false 147 | } 148 | 149 | /** 150 | * Populate the extensions and types maps. 151 | * @private 152 | */ 153 | 154 | function populateMaps (extensions, types) { 155 | // source preference (least -> most) 156 | var preference = ['nginx', 'apache', undefined, 'iana'] 157 | 158 | Object.keys(db).forEach(function forEachMimeType (type) { 159 | var mime = db[type] 160 | var exts = mime.extensions 161 | 162 | if (!exts || !exts.length) { 163 | return 164 | } 165 | 166 | // mime -> extensions 167 | extensions[type] = exts 168 | 169 | // extension -> mime 170 | for (var i = 0; i < exts.length; i++) { 171 | var extension = exts[i] 172 | 173 | if (types[extension]) { 174 | var from = preference.indexOf(db[types[extension]].source) 175 | var to = preference.indexOf(mime.source) 176 | 177 | if (types[extension] !== 'application/octet-stream' && 178 | (from > to || (from === to && types[extension].substr(0, 12) === 'application/'))) { 179 | // skip the remapping 180 | continue 181 | } 182 | } 183 | 184 | // set the extension -> mime 185 | types[extension] = type 186 | } 187 | }) 188 | } 189 | -------------------------------------------------------------------------------- /mime-types/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mime-types", 3 | "description": "The ultimate javascript content-type utility.", 4 | "version": "2.1.22", 5 | "contributors": [ 6 | "Douglas Christopher Wilson ", 7 | "Jeremiah Senkpiel (https://searchbeam.jit.su)", 8 | "Jonathan Ong (http://jongleberry.com)" 9 | ], 10 | "license": "MIT", 11 | "keywords": [ 12 | "mime", 13 | "types" 14 | ], 15 | "repository": "jshttp/mime-types", 16 | "dependencies": { 17 | "mime-db": "~1.38.0" 18 | }, 19 | "alias": { 20 | "mime-db": "../dist/browser-mime-db.json" 21 | }, 22 | "devDependencies": { 23 | "eslint": "5.13.0", 24 | "eslint-config-standard": "12.0.0", 25 | "eslint-plugin-import": "2.16.0", 26 | "eslint-plugin-node": "7.0.1", 27 | "eslint-plugin-promise": "4.0.1", 28 | "eslint-plugin-standard": "4.0.0", 29 | "mocha": "5.2.0", 30 | "nyc": "13.3.0" 31 | }, 32 | "files": [ 33 | "HISTORY.md", 34 | "LICENSE", 35 | "index.js" 36 | ], 37 | "engines": { 38 | "node": ">= 0.6" 39 | }, 40 | "scripts": { 41 | "lint": "eslint .", 42 | "test": "mocha --reporter spec test/test.js", 43 | "test-cov": "nyc --reporter=html --reporter=text npm test", 44 | "test-travis": "nyc --reporter=text npm test" 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /mime-types/test/.eslintrc.yml: -------------------------------------------------------------------------------- 1 | env: 2 | mocha: true 3 | -------------------------------------------------------------------------------- /mime-types/test/test.js: -------------------------------------------------------------------------------- 1 | 2 | var assert = require('assert') 3 | var mimeTypes = require('..') 4 | 5 | describe('mimeTypes', function () { 6 | describe('.charset(type)', function () { 7 | it('should return "UTF-8" for "application/json"', function () { 8 | assert.strictEqual(mimeTypes.charset('application/json'), 'UTF-8') 9 | }) 10 | 11 | it('should return "UTF-8" for "application/json; foo=bar"', function () { 12 | assert.strictEqual(mimeTypes.charset('application/json; foo=bar'), 'UTF-8') 13 | }) 14 | 15 | it('should return "UTF-8" for "application/javascript"', function () { 16 | assert.strictEqual(mimeTypes.charset('application/javascript'), 'UTF-8') 17 | }) 18 | 19 | it('should return "UTF-8" for "application/JavaScript"', function () { 20 | assert.strictEqual(mimeTypes.charset('application/JavaScript'), 'UTF-8') 21 | }) 22 | 23 | it('should return "UTF-8" for "text/html"', function () { 24 | assert.strictEqual(mimeTypes.charset('text/html'), 'UTF-8') 25 | }) 26 | 27 | it('should return "UTF-8" for "TEXT/HTML"', function () { 28 | assert.strictEqual(mimeTypes.charset('TEXT/HTML'), 'UTF-8') 29 | }) 30 | 31 | it('should return "UTF-8" for any text/*', function () { 32 | assert.strictEqual(mimeTypes.charset('text/x-bogus'), 'UTF-8') 33 | }) 34 | 35 | it('should return false for unknown types', function () { 36 | assert.strictEqual(mimeTypes.charset('application/x-bogus'), false) 37 | }) 38 | 39 | it('should return false for any application/octet-stream', function () { 40 | assert.strictEqual(mimeTypes.charset('application/octet-stream'), false) 41 | }) 42 | 43 | it('should return false for invalid arguments', function () { 44 | assert.strictEqual(mimeTypes.charset({}), false) 45 | assert.strictEqual(mimeTypes.charset(null), false) 46 | assert.strictEqual(mimeTypes.charset(true), false) 47 | assert.strictEqual(mimeTypes.charset(42), false) 48 | }) 49 | }) 50 | 51 | describe('.contentType(extension)', function () { 52 | it('should return content-type for "html"', function () { 53 | assert.strictEqual(mimeTypes.contentType('html'), 'text/html; charset=utf-8') 54 | }) 55 | 56 | it('should return content-type for ".html"', function () { 57 | assert.strictEqual(mimeTypes.contentType('.html'), 'text/html; charset=utf-8') 58 | }) 59 | 60 | it('should return content-type for "jade"', function () { 61 | assert.strictEqual(mimeTypes.contentType('jade'), 'text/jade; charset=utf-8') 62 | }) 63 | 64 | it('should return content-type for "json"', function () { 65 | assert.strictEqual(mimeTypes.contentType('json'), 'application/json; charset=utf-8') 66 | }) 67 | 68 | it('should return false for unknown extensions', function () { 69 | assert.strictEqual(mimeTypes.contentType('bogus'), false) 70 | }) 71 | 72 | it('should return false for invalid arguments', function () { 73 | assert.strictEqual(mimeTypes.contentType({}), false) 74 | assert.strictEqual(mimeTypes.contentType(null), false) 75 | assert.strictEqual(mimeTypes.contentType(true), false) 76 | assert.strictEqual(mimeTypes.contentType(42), false) 77 | }) 78 | }) 79 | 80 | describe('.contentType(type)', function () { 81 | it('should attach charset to "application/json"', function () { 82 | assert.strictEqual(mimeTypes.contentType('application/json'), 'application/json; charset=utf-8') 83 | }) 84 | 85 | it('should attach charset to "application/json; foo=bar"', function () { 86 | assert.strictEqual(mimeTypes.contentType('application/json; foo=bar'), 'application/json; foo=bar; charset=utf-8') 87 | }) 88 | 89 | it('should attach charset to "TEXT/HTML"', function () { 90 | assert.strictEqual(mimeTypes.contentType('TEXT/HTML'), 'TEXT/HTML; charset=utf-8') 91 | }) 92 | 93 | it('should attach charset to "text/html"', function () { 94 | assert.strictEqual(mimeTypes.contentType('text/html'), 'text/html; charset=utf-8') 95 | }) 96 | 97 | it('should not alter "text/html; charset=iso-8859-1"', function () { 98 | assert.strictEqual(mimeTypes.contentType('text/html; charset=iso-8859-1'), 'text/html; charset=iso-8859-1') 99 | }) 100 | 101 | it('should return type for unknown types', function () { 102 | assert.strictEqual(mimeTypes.contentType('application/x-bogus'), 'application/x-bogus') 103 | }) 104 | }) 105 | 106 | describe('.extension(type)', function () { 107 | it('should return extension for mime type', function () { 108 | assert.strictEqual(mimeTypes.extension('text/html'), 'html') 109 | assert.strictEqual(mimeTypes.extension(' text/html'), 'html') 110 | assert.strictEqual(mimeTypes.extension('text/html '), 'html') 111 | }) 112 | 113 | it('should return false for unknown type', function () { 114 | assert.strictEqual(mimeTypes.extension('application/x-bogus'), false) 115 | }) 116 | 117 | it('should return false for non-type string', function () { 118 | assert.strictEqual(mimeTypes.extension('bogus'), false) 119 | }) 120 | 121 | it('should return false for non-strings', function () { 122 | assert.strictEqual(mimeTypes.extension(null), false) 123 | assert.strictEqual(mimeTypes.extension(undefined), false) 124 | assert.strictEqual(mimeTypes.extension(42), false) 125 | assert.strictEqual(mimeTypes.extension({}), false) 126 | }) 127 | 128 | it('should return extension for mime type with parameters', function () { 129 | assert.strictEqual(mimeTypes.extension('text/html;charset=UTF-8'), 'html') 130 | assert.strictEqual(mimeTypes.extension('text/HTML; charset=UTF-8'), 'html') 131 | assert.strictEqual(mimeTypes.extension('text/html; charset=UTF-8'), 'html') 132 | assert.strictEqual(mimeTypes.extension('text/html; charset=UTF-8 '), 'html') 133 | assert.strictEqual(mimeTypes.extension('text/html ; charset=UTF-8'), 'html') 134 | }) 135 | }) 136 | 137 | describe('.lookup(extension)', function () { 138 | it('should return mime type for ".html"', function () { 139 | assert.strictEqual(mimeTypes.lookup('.html'), 'text/html') 140 | }) 141 | 142 | it('should return mime type for ".js"', function () { 143 | assert.strictEqual(mimeTypes.lookup('.js'), 'application/javascript') 144 | }) 145 | 146 | it('should return mime type for ".json"', function () { 147 | assert.strictEqual(mimeTypes.lookup('.json'), 'application/json') 148 | }) 149 | 150 | it('should return mime type for ".rtf"', function () { 151 | assert.strictEqual(mimeTypes.lookup('.rtf'), 'application/rtf') 152 | }) 153 | 154 | it('should return mime type for ".txt"', function () { 155 | assert.strictEqual(mimeTypes.lookup('.txt'), 'text/plain') 156 | }) 157 | 158 | it('should return mime type for ".xml"', function () { 159 | assert.strictEqual(mimeTypes.lookup('.xml'), 'application/xml') 160 | }) 161 | 162 | it('should work without the leading dot', function () { 163 | assert.strictEqual(mimeTypes.lookup('html'), 'text/html') 164 | assert.strictEqual(mimeTypes.lookup('xml'), 'application/xml') 165 | }) 166 | 167 | it('should be case insensitive', function () { 168 | assert.strictEqual(mimeTypes.lookup('HTML'), 'text/html') 169 | assert.strictEqual(mimeTypes.lookup('.Xml'), 'application/xml') 170 | }) 171 | 172 | it('should return false for unknown extension', function () { 173 | assert.strictEqual(mimeTypes.lookup('.bogus'), false) 174 | assert.strictEqual(mimeTypes.lookup('bogus'), false) 175 | }) 176 | 177 | it('should return false for non-strings', function () { 178 | assert.strictEqual(mimeTypes.lookup(null), false) 179 | assert.strictEqual(mimeTypes.lookup(undefined), false) 180 | assert.strictEqual(mimeTypes.lookup(42), false) 181 | assert.strictEqual(mimeTypes.lookup({}), false) 182 | }) 183 | }) 184 | 185 | describe('.lookup(path)', function () { 186 | it('should return mime type for file name', function () { 187 | assert.strictEqual(mimeTypes.lookup('page.html'), 'text/html') 188 | }) 189 | 190 | it('should return mime type for relative path', function () { 191 | assert.strictEqual(mimeTypes.lookup('path/to/page.html'), 'text/html') 192 | assert.strictEqual(mimeTypes.lookup('path\\to\\page.html'), 'text/html') 193 | }) 194 | 195 | it('should return mime type for absolute path', function () { 196 | assert.strictEqual(mimeTypes.lookup('/path/to/page.html'), 'text/html') 197 | assert.strictEqual(mimeTypes.lookup('C:\\path\\to\\page.html'), 'text/html') 198 | }) 199 | 200 | it('should be case insensitive', function () { 201 | assert.strictEqual(mimeTypes.lookup('/path/to/PAGE.HTML'), 'text/html') 202 | assert.strictEqual(mimeTypes.lookup('C:\\path\\to\\PAGE.HTML'), 'text/html') 203 | }) 204 | 205 | it('should return false for unknown extension', function () { 206 | assert.strictEqual(mimeTypes.lookup('/path/to/file.bogus'), false) 207 | }) 208 | 209 | it('should return false for path without extension', function () { 210 | assert.strictEqual(mimeTypes.lookup('/path/to/json'), false) 211 | }) 212 | 213 | describe('path with dotfile', function () { 214 | it('should return false when extension-less', function () { 215 | assert.strictEqual(mimeTypes.lookup('/path/to/.json'), false) 216 | }) 217 | 218 | it('should return mime type when there is extension', function () { 219 | assert.strictEqual(mimeTypes.lookup('/path/to/.config.json'), 'application/json') 220 | }) 221 | 222 | it('should return mime type when there is extension, but no path', function () { 223 | assert.strictEqual(mimeTypes.lookup('.config.json'), 'application/json') 224 | }) 225 | }) 226 | }) 227 | }) 228 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "browser-mime", 3 | "version": "1.0.1", 4 | "description": "MIME types for use in browsers", 5 | "repository": "github:humphd/browser-mime", 6 | "devDependencies": { 7 | "chalk": "^2.4.2", 8 | "eslint": "^5.16.0", 9 | "express": "^4.16.4", 10 | "express-handlebars": "^3.0.2", 11 | "mime-db": "^1.38.0", 12 | "mocha": "^6.0.2", 13 | "parcel": "^1.12.3", 14 | "puppeteer": "^1.14.0", 15 | "release-it": "^10.4.0", 16 | "run.env": "^1.1.0" 17 | }, 18 | "scripts": { 19 | "test": "mocha test", 20 | "update-mime-types": "git subtree pull --prefix mime-types https://github.com/jshttp/mime-types.git master --squash", 21 | "build-db": "node tools/build-db.js", 22 | "build": "parcel build mime-types/index.js --detailed-report", 23 | "mime-server": "node ./tools/server-cli.js", 24 | "eslint": "eslint tools test views", 25 | "release": "run.env release-it" 26 | }, 27 | "main": "dist/index.js", 28 | "browser": "dist/index.js", 29 | "files": [ 30 | "dist" 31 | ], 32 | "author": "David Humphrey ", 33 | "license": "MIT", 34 | "dependencies": {} 35 | } 36 | -------------------------------------------------------------------------------- /src/initial-db.json: -------------------------------------------------------------------------------- 1 | { 2 | "application/xhtml+xml": { 3 | "extensions": ["xhtml","xht","xhtm"] 4 | }, 5 | "text/html": { 6 | "extensions": ["html","htm","shtml","shtm"] 7 | }, 8 | "image/apng": { 9 | "extensions": ["apng"] 10 | }, 11 | "application/wasm": { 12 | "extensions": ["wasm"] 13 | }, 14 | "audio/mp3": { 15 | "extensions": ["mp3"] 16 | }, 17 | "audio/wav": { 18 | "extensions": ["wav"] 19 | }, 20 | "audio/x-flac": { 21 | "extensions": ["flac"] 22 | }, 23 | "audio/x-m4a": { 24 | "extensions": ["m4a"] 25 | }, 26 | "application/javascript": { 27 | "charset": "UTF-8", 28 | "extensions": ["js","mjs"] 29 | }, 30 | "video/x-m4v": { 31 | "extensions": ["m4v"] 32 | }, 33 | "video/ogg": { 34 | "extensions": ["ogv", "ogm"] 35 | }, 36 | "application/epub+zip": { 37 | "extensions": ["epub"] 38 | }, 39 | "application/pdf": { 40 | "extensions": ["pdf"] 41 | }, 42 | "video/mpeg": { 43 | "extensions": ["mpeg","mpg","mpe","m1v","m2v"] 44 | }, 45 | "audio/mpeg": { 46 | "extensions": ["mpga","mp2","mp2a","mp3","m2a","m3a"] 47 | }, 48 | "font/otf": { 49 | "extensions": ["otf"] 50 | }, 51 | "font/ttf": { 52 | "extensions": ["ttf"] 53 | }, 54 | "font/woff": { 55 | "extensions": ["woff"] 56 | }, 57 | "font/woff2": { 58 | "extensions": ["woff2"] 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /test/chromium-types.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | browser: 'Chromium', 3 | mimeTypes: [ 4 | // based on https://chromium.googlesource.com/chromium/src/+/94493c6554081529c04eea5b97a1f2ff2649e4a8/net/base/mime_util.cc 5 | { type: 'video/webm', extensions: 'webm' }, 6 | { type: 'application/wasm', extensions: 'wasm' }, 7 | { type: 'application/xhtml+xml', extensions: 'xhtml,xht,xhtm' }, 8 | { type: 'audio/x-flac', extensions: 'flac' }, // humphd: changed to x-flac (per db.json) 9 | { type: 'audio/mp3', extensions: 'mp3' }, 10 | { type: 'audio/ogg', extensions: 'ogg,oga' }, // humphd: removed opus extension 11 | { type: 'audio/wav', extensions: 'wav' }, 12 | { type: 'audio/x-m4a', extensions: 'm4a' }, 13 | { type: 'image/gif', extensions: 'gif' }, 14 | { type: 'image/jpeg', extensions: 'jpeg,jpg' }, 15 | { type: 'image/png', extensions: 'png' }, 16 | { type: 'image/apng', extensions: 'apng' }, // humphd: added apng 17 | { type: 'image/webp', extensions: 'webp' }, 18 | { type: 'text/css', extensions: 'css' }, 19 | { type: 'text/html', extensions: 'html,htm,shtml,shtm' }, 20 | { type: 'text/plain', extensions: 'txt,text' }, 21 | { type: 'text/xml', extensions: 'xml,xsl' }, 22 | { type: 'video/mp4', extensions: 'mp4,m4v' }, 23 | { type: 'video/ogg', extensions: 'ogv,ogm' }, 24 | { type: 'image/x-icon', extensions: 'ico' }, 25 | { type: 'application/epub+zip', extensions: 'epub' }, 26 | { type: 'font/woff', extensions: 'woff' }, // humphd: switched from application/font-woff 27 | { type: 'application/javascript', extensions: 'js' }, 28 | { type: 'application/json', extensions: 'json' }, 29 | { type: 'application/pdf', extensions: 'pdf' }, 30 | { type: 'image/bmp', extensions: 'bmp' }, 31 | { type: 'image/svg+xml', extensions: 'svg,svgz' }, 32 | { type: 'video/mpeg', extensions: 'mpeg,mpg' } 33 | ] 34 | }; 35 | 36 | -------------------------------------------------------------------------------- /test/test.js: -------------------------------------------------------------------------------- 1 | const assert = require('assert'); 2 | const mime = require('..'); 3 | const mimeDatabase = require('../dist/browser-mime-db.json'); 4 | const chromiumTypes = require('./chromium-types'); 5 | const webkitTypes = require('./webkit-types'); 6 | 7 | [chromiumTypes, webkitTypes].forEach((browserType) => { 8 | const { browser, mimeTypes } = browserType; 9 | 10 | describe(`${browser} MIME Types`, () => { 11 | mimeTypes.forEach(mimeType => { 12 | let { type, extensions } = mimeType; 13 | 14 | // Make sure the mime type exists in our browser db 15 | it(`supports '${mimeType.type}'`, 16 | () => assert(mimeDatabase[type])); 17 | 18 | // Also check that all of the associated extensions have types 19 | extensions = extensions.split(','); 20 | extensions.forEach(ext => { 21 | it(`supports '${ext}' extension for '${mimeType.type}'`, 22 | () => assert(mime.lookup(ext)) 23 | ); 24 | }); 25 | }); 26 | }); 27 | }); 28 | -------------------------------------------------------------------------------- /test/webkit-types.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | browser: 'WebKit', 3 | mimeTypes: [ 4 | // based on https://github.com/WebKit/webkit/blob/8e95493b2c7ce6ceb07b3d61f256741714482d07/Source/WebCore/platform/MIMETypeRegistry.cpp 5 | { type: 'image/gif', extensions: 'gif' }, 6 | { type: 'image/jpeg', extensions: 'jpg' }, 7 | { type: 'image/bmp', extensions: 'bmp' }, 8 | { type: 'image/png', extensions: 'png' }, 9 | { type: 'image/webp', extensions: 'webp' }, 10 | { type: 'image/svg+xml', extensions: 'svg' }, 11 | 12 | { type: 'application/javascript', extensions: 'js' }, 13 | { type: 'application/json', extensions: 'json' }, 14 | 15 | { type: 'text/html', extensions: 'html' }, 16 | { type: 'text/xml', extensions: 'xml' }, 17 | { type: 'text/plain', extensions: 'txt' }, 18 | { type: 'application/xml', extensions: 'xml,xsl' }, 19 | { type: 'application/xhtml+xml', extensions: 'xhtml' }, 20 | 21 | { type: 'application/rss+xml', extensions: 'rss' }, 22 | { type: 'application/atom+xml', extensions: 'atom' }, 23 | 24 | { type: 'application/pdf', extensions: 'pdf' }, 25 | 26 | { type: 'font/woff', extensions: 'woff' }, 27 | { type: 'font/woff2', extensions: 'woff2' }, 28 | { type: 'font/otf', extensions: 'otf' }, 29 | { type: 'font/ttf', extensions: 'ttf' }, 30 | 31 | { type: 'application/ogg', extensions: 'ogx' }, 32 | { type: 'audio/ogg', extensions: 'ogg,oga' }, 33 | { type: 'video/ogg', extensions: 'ogv' }, 34 | 35 | { type: 'video/webm', extensions: 'webm' }, 36 | 37 | { type: 'audio/mp3', extensions: 'mp3' } 38 | ] 39 | }; 40 | -------------------------------------------------------------------------------- /tools/build-db.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const chalk = require('chalk'); 3 | const puppeteer = require('puppeteer'); 4 | /** 5 | * The mime-db object is organized by mime type, and 6 | * records look like this (some fields might be missing): 7 | * 8 | * "application/json": { 9 | * "source": "iana", 10 | * "charset": "UTF-8", 11 | * "compressible": true, 12 | * "extensions": ["json","map"] 13 | * } 14 | */ 15 | const mime = require('mime-db'); 16 | const server = require('./server'); 17 | 18 | // Our new browser mime db. We pre-seed it with some types we know should 19 | // exist, but don't necessarily follow the design of our automated test below. 20 | const browserMime = require('../src/initial-db.json'); 21 | 22 | async function processAllMimeTypes(browser) { 23 | const port = server.start(); 24 | 25 | async function testMimeType(mimeType) { 26 | return new Promise(async (resolve) => { 27 | const page = await browser.newPage(); 28 | 29 | // Wait on something to get logged to the console (see views/public/index.js) 30 | page.on('console', async msg => { 31 | let supported; 32 | try { 33 | let result = JSON.parse(msg.text()); 34 | 35 | // We write a JSON string like {"mimeType": "text/plain", "supported": true}, 36 | // try to parse it and see if we should log it (success only). 37 | supported = result.supported; 38 | 39 | await page.close(); 40 | resolve(supported); 41 | } catch(e) { 42 | console.warn(chalk.gray(`Ignoring JSON parsing error for mime type='${mimeType}': ${msg.text()}`)); 43 | } 44 | }); 45 | 46 | await page.goto(`http://localhost:${port}/?mimeType=${encodeURIComponent(mimeType)}`); 47 | }); 48 | } 49 | 50 | // Loop through all mime type keys, and print any that are supported, with extensions 51 | for(const mimeType of Object.keys(mime)) { 52 | // Skip any types we already have pre-seeded in the db 53 | if(browserMime[mimeType]) { 54 | console.log(chalk.green(`${mimeType} - supported (manually included)`)); 55 | continue; 56 | } 57 | 58 | const supported = await testMimeType(mimeType); 59 | if(!supported) { 60 | console.log(chalk.red(`${mimeType} - not supported`)); 61 | } else { 62 | // Record this in our new db object 63 | const mimeInfo = mime[mimeType]; 64 | if(mimeInfo.extensions) { 65 | // Strip out the .source and .compressible properties. 66 | // We don't need them (or the extra size) 67 | delete mimeInfo.source; 68 | delete mimeInfo.compressible; 69 | browserMime[mimeType] = mimeInfo; 70 | console.log(chalk.green(`${mimeType} - supported`)); 71 | } else { 72 | console.log(chalk.yellow(`${mimeType} - supported, but no extensions, ignoring`)); 73 | } 74 | } 75 | } 76 | 77 | // Write out the new db file 78 | const json = JSON.stringify(browserMime, null, 2); 79 | fs.writeFile('dist/browser-mime-db.json', json, async (err) => { 80 | if(err) { 81 | console.error(chalk.red('Unable to write browser-mime-db.json'), err.message); 82 | } else { 83 | console.log('Wrote browser-mime-db.json'); 84 | } 85 | 86 | // Shut down our testing server and browser 87 | await browser.close(); 88 | server.stop(); 89 | }); 90 | } 91 | 92 | puppeteer.launch().then(processAllMimeTypes); 93 | -------------------------------------------------------------------------------- /tools/server-cli.js: -------------------------------------------------------------------------------- 1 | const server = require('./server'); 2 | 3 | const port = server.start(); 4 | console.log(`http://localhost:${port}`); -------------------------------------------------------------------------------- /tools/server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const expressHandlebars = require('express-handlebars'); 3 | const app = express(); 4 | const DEFAULT_PORT = 3000; 5 | 6 | // See Handlebars templates in views/ 7 | app.engine('handlebars', expressHandlebars({defaultLayout: 'main'})); 8 | app.set('view engine', 'handlebars') 9 | 10 | // Make sure we get something that looks like a mimeType 11 | function isMimeType(mimeType) { 12 | return mimeType && /[^/]+\/.+/.test(mimeType); 13 | } 14 | 15 | app.get('/mime/*', (request, response) => { 16 | const mimeType = request.params[0]; 17 | 18 | if(!isMimeType(mimeType)) { 19 | return response.status(400); 20 | } 21 | 22 | // Use whatever mime type we're given on the route and 23 | // send an empty buffer back of that type. 24 | response.set('Content-Type', mimeType); 25 | response.send(Buffer.alloc(0)); 26 | }); 27 | 28 | // Expect to get a mime type on the query string: ?mimeType=text/plain 29 | app.get('/', (request, response) => { 30 | const mimeType = request.query.mimeType; 31 | 32 | if(!isMimeType(mimeType)) { 33 | return response.status(400); 34 | } 35 | 36 | response.render('mime', { mimeType }); 37 | }); 38 | 39 | // Handlebars templates, and static JS for browser are all in views/ 40 | app.use(express.static('views/public/')); 41 | 42 | let server; 43 | 44 | function start(port = DEFAULT_PORT) { 45 | server = app.listen(port, (err) => { 46 | if (err) { 47 | throw err; 48 | } 49 | }); 50 | 51 | return port; 52 | } 53 | 54 | function stop() { 55 | server.close(); 56 | } 57 | 58 | module.exports.start = start; 59 | module.exports.stop = stop; 60 | -------------------------------------------------------------------------------- /views/layouts/main.handlebars: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | MIME Check 6 | 7 | 8 | {{{body}}} 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /views/mime.handlebars: -------------------------------------------------------------------------------- 1 | 5 | -------------------------------------------------------------------------------- /views/public/index.js: -------------------------------------------------------------------------------- 1 | window.onload = function() { 2 | const iframe = document.querySelector('iframe'); 3 | const iframeWindow = iframe.contentWindow.window; 4 | 5 | /** 6 | * Check to see if the iframe has navigation timing info 7 | * or not. If it does, the browser downloaded and tried to 8 | * use the content (e.g., render). If not, it gave up on the 9 | * resource and gave a Download... dialog instead. 10 | */ 11 | function inspectTimingInfo() { 12 | const perfEntries = iframeWindow.performance.getEntriesByType('navigation'); 13 | console.log(JSON.stringify({ 14 | mimeType: iframe.dataset.mimeType, 15 | supported: !!(perfEntries && perfEntries.length > 0) 16 | })); 17 | } 18 | 19 | setTimeout(inspectTimingInfo, 100); 20 | }; 21 | --------------------------------------------------------------------------------