( encoding: string, accepted: Specificity[], index: number, )
| 115 | } |
| 116 | |
| 117 | function getEncodingPriority( |
| 118 | encoding: string, |
| 119 | accepted: Specificity[], |
| 120 | index: number, |
| 121 | ): Specificity { |
| 122 | let priority: Specificity = { o: -1, q: 0, s: 0, i: 0 }; |
| 123 | |
| 124 | for (const s of accepted) { |
| 125 | const spec = specify(encoding, s, index); |
| 126 | |
| 127 | if ( |
| 128 | spec && |
| 129 | (priority.s! - spec.s! || priority.q - spec.q || |
| 130 | priority.o! - spec.o!) < |
| 131 | 0 |
| 132 | ) { |
| 133 | priority = spec; |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | return priority; |
| 138 | } |
| 139 | |
| 140 | /** Given an `Accept-Encoding` string, parse out the encoding returning a |
| 141 | * negotiated encoding based on the `provided` encodings otherwise just a |
no test coverage detected