dist/mimetypes.js
function detectExtension() {
  var mimeType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  var favoredExtension = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';

  mimeType = mimeType.toString().toLowerCase().replace(/\s/g, '');
  if (!(mimeType in _listTypes.types)) {
    return 'bin';
  }

  if (typeof _listTypes.types[mimeType] === 'string') {
    return _listTypes.types[mimeType];
  }

  favoredExtension = favoredExtension.toString().toLowerCase().replace(/\s/g, '');
  if (favoredExtension && _listTypes.types[mimeType].includes(favoredExtension)) {
    return favoredExtension;
  }

  // search for name match
  var mimePart = mimeType.split('/')[1];
  for (var i = 0, len = _listTypes.types[mimeType].length; i < len; i++) {
    if (mimePart === _listTypes.types[mimeType][i]) {
      return _listTypes.types[mimeType][i];
    }
  }

  // use the first one
  return _listTypes.types[mimeType][0];
}
function detectExtension() {
  var mimeType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  var favoredExtension = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';

  mimeType = mimeType.toString().toLowerCase().replace(/\s/g, '');
  if (!(mimeType in _listTypes.types)) {
    return 'bin';
  }

  if (typeof _listTypes.types[mimeType] === 'string') {
    return _listTypes.types[mimeType];
  }

  favoredExtension = favoredExtension.toString().toLowerCase().replace(/\s/g, '');
  if (favoredExtension && _listTypes.types[mimeType].includes(favoredExtension)) {
    return favoredExtension;
  }

  // search for name match
  var mimePart = mimeType.split('/')[1];
  for (var i = 0, len = _listTypes.types[mimeType].length; i < len; i++) {
    if (mimePart === _listTypes.types[mimeType][i]) {
      return _listTypes.types[mimeType][i];
    }
  }

  // use the first one
  return _listTypes.types[mimeType][0];
}
function detectExtension ( ) { var mimeType = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : '' ; var favoredExtension = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : '' ; mimeType = mimeType . toString ( ) . toLowerCase ( ) . replace ( / \s / g , '' ) ; if ( ! ( mimeType in _listTypes . types ) ) { return 'bin' ; } if ( typeof _listTypes . types [ mimeType ] === 'string' ) { return _listTypes . types [ mimeType ] ; } favoredExtension = favoredExtension . toString ( ) . toLowerCase ( ) . replace ( / \s / g , '' ) ; if ( favoredExtension && _listTypes . types [ mimeType ] . includes ( favoredExtension ) ) { return favoredExtension ; } // search for name match var mimePart = mimeType . split ( '/' ) [ 1 ] ; for ( var i = 0 , len = _listTypes . types [ mimeType ] . length ; i < len ; i ++ ) { if ( mimePart === _listTypes . types [ mimeType ] [ i ] ) { return _listTypes . types [ mimeType ] [ i ] ; } } // use the first one return _listTypes . types [ mimeType ] [ 0 ] ; }
Returns file extension for a content type string. If no suitable extensions
are found, 'bin' is used as the default extension

@param {String} mimeType Content type to be checked for
@return {String} File extension
Returns file extension for a content type string . If no suitable extensions are found bin is used as the default extension