Resolve a directive argument that may be either a token or a quoted-string * (RFC 9111 §5.2). When the value is a quoted-string, surrounding double * quotes are stripped and quoted-pair sequences (`\\X`) are unescaped per * RFC 9110 §5.6.4.
(value: string)
| 156 | * quotes are stripped and quoted-pair sequences (`\\X`) are unescaped per |
| 157 | * RFC 9110 §5.6.4. */ |
| 158 | function unquoteArgument(value: string): string { |
| 159 | const t = value.trim(); |
| 160 | if (t.length >= 2 && t.startsWith('"') && t.endsWith('"')) { |
| 161 | return t.slice(1, -1).replace(/\\(.)/g, "$1"); |
| 162 | } |
| 163 | return t; |
| 164 | } |
| 165 | |
| 166 | function parseNonNegativeInt(value: string, directive: string): number { |
| 167 | const trimmed = unquoteArgument(value); |
no test coverage detected