index.js
function mimeMatch (expected, actual) {
  // invalid type
  if (expected === false) {
    return false
  }

  // split types
  var actualParts = actual.split('/')
  var expectedParts = expected.split('/')

  // invalid format
  if (actualParts.length !== 2 || expectedParts.length !== 2) {
    return false
  }

  // validate type
  if (expectedParts[0] !== '*' && expectedParts[0] !== actualParts[0]) {
    return false
  }

  // validate suffix wildcard
  if (expectedParts[1].substr(0, 2) === '*+') {
    return expectedParts[1].length <= actualParts[1].length + 1 &&
      expectedParts[1].substr(1) === actualParts[1].substr(1 - expectedParts[1].length)
  }

  // validate subtype
  if (expectedParts[1] !== '*' && expectedParts[1] !== actualParts[1]) {
    return false
  }

  return true
}
function mimeMatch (expected, actual) {
  // invalid type
  if (expected === false) {
    return false
  }

  // split types
  var actualParts = actual.split('/')
  var expectedParts = expected.split('/')

  // invalid format
  if (actualParts.length !== 2 || expectedParts.length !== 2) {
    return false
  }

  // validate type
  if (expectedParts[0] !== '*' && expectedParts[0] !== actualParts[0]) {
    return false
  }

  // validate suffix wildcard
  if (expectedParts[1].substr(0, 2) === '*+') {
    return expectedParts[1].length <= actualParts[1].length + 1 &&
      expectedParts[1].substr(1) === actualParts[1].substr(1 - expectedParts[1].length)
  }

  // validate subtype
  if (expectedParts[1] !== '*' && expectedParts[1] !== actualParts[1]) {
    return false
  }

  return true
}
function mimeMatch ( expected , actual ) { // invalid type if ( expected === false ) { return false } // split types var actualParts = actual . split ( '/' ) var expectedParts = expected . split ( '/' ) // invalid format if ( actualParts . length !== 2 || expectedParts . length !== 2 ) { return false } // validate type if ( expectedParts [ 0 ] !== '*' && expectedParts [ 0 ] !== actualParts [ 0 ] ) { return false } // validate suffix wildcard if ( expectedParts [ 1 ] . substr ( 0 , 2 ) === '*+' ) { return expectedParts [ 1 ] . length <= actualParts [ 1 ] . length + 1 && expectedParts [ 1 ] . substr ( 1 ) === actualParts [ 1 ] . substr ( 1 - expectedParts [ 1 ] . length ) } // validate subtype if ( expectedParts [ 1 ] !== '*' && expectedParts [ 1 ] !== actualParts [ 1 ] ) { return false } return true }
Check if `expected` mime type
matches `actual` mime type with
wildcard and +suffix support.

@param {String} expected
@param {String} actual
@return {Boolean}
@private
Check if expected mime type matches actual mime type with wildcard and + suffix support .