Skip to content
Myr

mime() is no longer global. Renamed to exports.type()

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by visionmedia · committed by visionmedia · parent 944f99a · Browse files · 5 files+44 added−37 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+44 added−37 removed

  • tests:+33 added−25 removed
  • other:+11 added−12 removed

5 files+44 added−37 removed

modified:lib/express/core.js-1 removed
5 unmodified lines
6process.mixin(require('express/collection'))7process.mixin(require('express/event'))8process.mixin(require('express/request'))9process.mixin(require('express/plugin'))10process.mixin(require('express/mime'))10process.mixin(require('express/dsl'))1112/**13 * Module dependencies.
319 unmodified lines
modified:lib/express/mime.js+6 added-5 removed
348 unmodified lines
349 * By default 'application/octet-stream' is returned,350 * however this can be altered using the 'default mime type'351 * setting.352 *353 * mime('png') // => 'image/png'354 * mime('.png') // => 'image/png'355 * mime('image.png') // => 'image/png'356 * mime('path/to/image.png') // => 'image/png'353 * var mime = require('express/mime')354 * mime.type('png') // => 'image/png'355 * mime.type('.png') // => 'image/png'356 * mime.type('image.png') // => 'image/png'357 * mime.type('path/to/image.png') // => 'image/png'358 *359 * @param {string} path360 * @return {string}361 * @settings 'default mime type'362 * @api public363 */364364exports.mime = function(path) {365exports.type = function(path) {366 return exports.types[path] || 367 exports.types[utils.extname(path)] || 368 set('default mime type') || 369 'application/octet-stream'
1 unmodified line
modified:lib/express/request.js+5 added-6 removed
6 unmodified lines
78var StaticFile = require('express/static').File,9 statusBodies = require('http').STATUS_CODES,10 queryString = require('querystring'),11 mime = require('express/mime'),12 url = require('url')1314// --- InvalidStatusCode15
96 unmodified lines
112 },113 114 /**115 * Check if Accept header includes the mime type115 * for the given _path_, which calls mime().116 * for the given _path_, which calls mime.type().117 *118 * When no Accept header is present true will be119 * returned as stated in the HTTP specification.120 *121 * @param {string} path122 * @return {bool}122 * @see mime()123 * @api public124 */125126 accepts: function(path) {127 return this.header('accept') ? 128 this.header('accept').indexOf(mime(path)) !== -1 :128 this.header('accept').indexOf(mime.type(path)) !== -1 :129 true130 },131132 /**
52 unmodified lines
185 },186 187 /**188 * Set Content-Type header to the mime type189 * for the given _path_, which calls mime().189 * for the given _path_, which calls mime.type().190 *191 * @param {string} path192 * @return {Request}193 * @see mime()193 * @api public194 */195196 contentType: function(path) {198 this.header('content-type', mime(path))197 this.header('content-type', mime.type(path))198 return this199 },200 201 /**
61 unmodified lines
modified:spec/spec.mime.js+30 added-24 removed
modified:spec/spec.plugins.js+3 added-1 removed