* @see https://fetch.spec.whatwg.org/#header-value-get-decode-and-split * @param {string|null} value
(value)
| 1350 | * @param {string|null} value |
| 1351 | */ |
| 1352 | function gettingDecodingSplitting (value) { |
| 1353 | // 1. Let input be the result of isomorphic decoding value. |
| 1354 | const input = value |
| 1355 | |
| 1356 | // 2. Let position be a position variable for input, initially pointing at the start of input. |
| 1357 | const position = { position: 0 } |
| 1358 | |
| 1359 | // 3. Let values be a list of strings, initially empty. |
| 1360 | const values = [] |
| 1361 | |
| 1362 | // 4. Let temporaryValue be the empty string. |
| 1363 | let temporaryValue = '' |
| 1364 | |
| 1365 | // 5. While position is not past the end of input: |
| 1366 | while (position.position < input.length) { |
| 1367 | // 5.1. Append the result of collecting a sequence of code points that are not U+0022 (") |
| 1368 | // or U+002C (,) from input, given position, to temporaryValue. |
| 1369 | temporaryValue += collectASequenceOfCodePoints( |
| 1370 | (char) => char !== '"' && char !== ',', |
| 1371 | input, |
| 1372 | position |
| 1373 | ) |
| 1374 | |
| 1375 | // 5.2. If position is not past the end of input, then: |
| 1376 | if (position.position < input.length) { |
| 1377 | // 5.2.1. If the code point at position within input is U+0022 ("), then: |
| 1378 | if (input.charCodeAt(position.position) === 0x22) { |
| 1379 | // 5.2.1.1. Append the result of collecting an HTTP quoted string from input, given position, to temporaryValue. |
| 1380 | temporaryValue += collectAnHTTPQuotedString( |
| 1381 | input, |
| 1382 | position |
| 1383 | ) |
| 1384 | |
| 1385 | // 5.2.1.2. If position is not past the end of input, then continue. |
| 1386 | if (position.position < input.length) { |
| 1387 | continue |
| 1388 | } |
| 1389 | } else { |
| 1390 | // 5.2.2. Otherwise: |
| 1391 | |
| 1392 | // 5.2.2.1. Assert: the code point at position within input is U+002C (,). |
| 1393 | assert(input.charCodeAt(position.position) === 0x2C) |
| 1394 | |
| 1395 | // 5.2.2.2. Advance position by 1. |
| 1396 | position.position++ |
| 1397 | } |
| 1398 | } |
| 1399 | |
| 1400 | // 5.3. Remove all HTTP tab or space from the start and end of temporaryValue. |
| 1401 | temporaryValue = removeChars(temporaryValue, true, true, (char) => char === 0x9 || char === 0x20) |
| 1402 | |
| 1403 | // 5.4. Append temporaryValue to values. |
| 1404 | values.push(temporaryValue) |
| 1405 | |
| 1406 | // 5.6. Set temporaryValue to the empty string. |
| 1407 | temporaryValue = '' |
| 1408 | } |
| 1409 |
no test coverage detected