(str)
| 145 | * @returns {Record<string, string>} parsed |
| 146 | */ |
| 147 | const parseKeyValuePairs = (str) => { |
| 148 | /** @type {Record<string, string>} */ |
| 149 | const result = {}; |
| 150 | for (const item of str.split(",")) { |
| 151 | const i = item.indexOf("="); |
| 152 | if (i >= 0) { |
| 153 | const key = item.slice(0, i).trim(); |
| 154 | const value = item.slice(i + 1).trim(); |
| 155 | result[key] = value; |
| 156 | } else { |
| 157 | const key = item.trim(); |
| 158 | if (!key) continue; |
| 159 | result[key] = key; |
| 160 | } |
| 161 | } |
| 162 | return result; |
| 163 | }; |
| 164 | |
| 165 | /** |
| 166 | * Parses cache control. |
no test coverage detected