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