How to use the mime._extensions function in mime

To help you get started, we’ve selected a few mime examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github papandreou / express-processimage / lib / processImage.js View on Github external
const Path = require('path');
const _ = require('underscore');
const httpErrors = require('httperrors');
const getFilterInfosAndTargetContentTypeFromQueryString = require('./getFilterInfosAndTargetContentTypeFromQueryString');
const mime = require('mime');
const stream = require('stream');
const accepts = require('accepts');
const hijackResponse = require('hijackresponse');
const isImageByExtension = {};

Object.keys(mime._extensions).forEach(contentType => {
  if (/^image\//.test(contentType)) {
    const extension = mime._extensions[contentType];
    isImageByExtension[extension] = true;
  }
});

isImageByExtension.jpg = true;

function isImageExtension(extension) {
  return isImageByExtension[extension.toLowerCase()];
}

module.exports = options => {
  options = options || {};

  if (
github papandreou / express-processimage / lib / processImage.js View on Github external
Object.keys(mime._extensions).forEach(contentType => {
  if (/^image\//.test(contentType)) {
    const extension = mime._extensions[contentType];
    isImageByExtension[extension] = true;
  }
});
github papandreou / express-processimage / lib / getFilterInfosAndTargetContentTypeFromQueryString.js View on Github external
function getMockFileNameForContentType(contentType) {
  if (contentType) {
    if (
      contentType === 'image/vnd.microsoft.icon' ||
      contentType === 'image/x-icon'
    ) {
      return '.ico';
    }
    return `.${mime._extensions[contentType]}`;
  }
}