(value: string, ...types: string[])
| 69 | * or a mime type. |
| 70 | */ |
| 71 | export const typeIs = (value: string, ...types: string[]) => { |
| 72 | let i: number |
| 73 | // remove parameters and normalize |
| 74 | const val = tryNormalizeType(value) |
| 75 | |
| 76 | // no type or invalid |
| 77 | if (!val) return false |
| 78 | |
| 79 | // no types, return the content type |
| 80 | if (!types || !types.length) return val |
| 81 | |
| 82 | let type: string |
| 83 | for (i = 0; i < types.length; i++) { |
| 84 | if (mimeMatch(normalize((type = types[i])), val)) { |
| 85 | return type[0] === '+' || type.indexOf('*') !== -1 ? val : type |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | // no matches |
| 90 | return false |
| 91 | } |
no test coverage detected