( str: string, i: number, )
| 38 | const simpleEncodingRegExp = /^\s*([^\s;]+)\s*(?:;(.*))?$/; |
| 39 | |
| 40 | function parseEncoding( |
| 41 | str: string, |
| 42 | i: number, |
| 43 | ): EncodingSpecificity | undefined { |
| 44 | const match = simpleEncodingRegExp.exec(str); |
| 45 | if (!match) { |
| 46 | return undefined; |
| 47 | } |
| 48 | |
| 49 | const encoding = match[1]!; |
| 50 | let q = 1; |
| 51 | if (match[2]) { |
| 52 | const params = match[2].split(";"); |
| 53 | for (const param of params) { |
| 54 | const p = param.trim().split("="); |
| 55 | if (p[0] === "q" && p[1]) { |
| 56 | q = parseFloat(p[1]); |
| 57 | break; |
| 58 | } |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | return { encoding, o: undefined, q, i, s: undefined }; |
| 63 | } |
| 64 | |
| 65 | function specify( |
| 66 | encoding: string, |
no outgoing calls
no test coverage detected