import mime from 'mime-types'

const getMimetypeFromFilename = name => {
  return mime.lookup(name) || 'application/octet-stream'
}

const mappingMimetypeSubtype = {
  word: 'text',
  text: 'text',
  zip: 'zip',
  pdf: 'pdf',
  spreadsheet: 'sheet',
  excel: 'sheet',
  sheet: 'sheet',
  presentation: 'slide',
  powerpoint: 'slide'
}

export const getFileMimetype = (collection, prefix = '') => (mime, name) => {
  const mimetype =
    mime === 'application/octet-stream'
      ? getMimetypeFromFilename(name.toLowerCase())
      : mime

  const [type, subtype] = mimetype.split('/')
  if (collection[prefix + type]) {
    return type
  }
  if (type === 'application') {
    const existingType = subtype.match(
      Object.keys(mappingMimetypeSubtype).join('|')
    )
    return existingType ? mappingMimetypeSubtype[existingType[0]] : undefined
  }
  return undefined
}

@@ -360,17 +360,16 @@
 etype = 
-(
 collecti
@@ -374,22 +374,8 @@
 tion
-, prefix = '')
  =%3E 
@@ -383,14 +383,24 @@
 mime
+ = ''
 , name
+ = ''
 ) =%3E
@@ -594,17 +594,8 @@
 ion%5B
-prefix + 
 type

Remove prefix option from getFileMimetypes