(value)
| 52 | } |
| 53 | |
| 54 | function splitCacheControlHeaderValue (value) { |
| 55 | const directives = [] |
| 56 | let start = 0 |
| 57 | let quoteStart = -1 |
| 58 | let inQuote = false |
| 59 | let escaped = false |
| 60 | |
| 61 | for (let i = 0; i < value.length; i++) { |
| 62 | if (inQuote) { |
| 63 | if (escaped) { |
| 64 | escaped = false |
| 65 | } else if (value[i] === '\\') { |
| 66 | escaped = true |
| 67 | } else if (value[i] === '"') { |
| 68 | inQuote = false |
| 69 | quoteStart = -1 |
| 70 | } |
| 71 | } else if (value[i] === '"') { |
| 72 | inQuote = true |
| 73 | quoteStart = i |
| 74 | } else if (value[i] === ',') { |
| 75 | directives.push({ value: value.substring(start, i), fromMalformedQuote: false }) |
| 76 | start = i + 1 |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | if (!inQuote) { |
| 81 | directives.push({ value: value.substring(start), fromMalformedQuote: false }) |
| 82 | return directives |
| 83 | } |
| 84 | |
| 85 | const tail = value.substring(start) |
| 86 | const quoteOffset = quoteStart - start |
| 87 | let tailStart = 0 |
| 88 | for (let i = 0; i < tail.length; i++) { |
| 89 | if (tail[i] === ',') { |
| 90 | directives.push({ |
| 91 | value: tail.substring(tailStart, i), |
| 92 | fromMalformedQuote: tailStart > quoteOffset |
| 93 | }) |
| 94 | tailStart = i + 1 |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | directives.push({ |
| 99 | value: tail.substring(tailStart), |
| 100 | fromMalformedQuote: tailStart > quoteOffset |
| 101 | }) |
| 102 | return directives |
| 103 | } |
| 104 | |
| 105 | function markInvalidCacheControlDirective (directives, key) { |
| 106 | let invalidDirectives = directives[kInvalidCacheControlDirectives] |
no test coverage detected