(type: string | unknown)
| 47 | } |
| 48 | |
| 49 | function normalize(type: string | unknown) { |
| 50 | // invalid type |
| 51 | if (typeof type !== 'string') return false |
| 52 | |
| 53 | switch (type) { |
| 54 | case 'urlencoded': |
| 55 | return 'application/x-www-form-urlencoded' |
| 56 | case 'multipart': |
| 57 | return 'multipart/*' |
| 58 | } |
| 59 | // "+json" -> "*/*+json" expando |
| 60 | if (type[0] === '+') return '*/*' + type |
| 61 | |
| 62 | return type.indexOf('/') === -1 ? lookup(type) : type |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Compare a `value` content-type with `types`. |