| 4 | ~type.indexOf('/') ? acceptParams(type) : { value: mime.lookup(type), params: {} } |
| 5 | |
| 6 | export function acceptParams(str: string, index?: number) { |
| 7 | const parts = str.split(/ *; */) |
| 8 | const ret = { value: parts[0], quality: 1, params: {}, originalIndex: index } |
| 9 | |
| 10 | for (const part of parts) { |
| 11 | const pms = part.split(/ *= */) |
| 12 | if ('q' === pms[0]) ret.quality = parseFloat(pms[1]) |
| 13 | else ret.params[pms[0]] = pms[1] |
| 14 | } |
| 15 | |
| 16 | return ret |
| 17 | } |
| 18 | |
| 19 | export function normalizeTypes(types: string[]) { |
| 20 | const ret = [] |