MCPcopy Create free account
hub / github.com/denoland/std / unquoteArgument

Function unquoteArgument

http/unstable_cache_control.ts:158–164  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

156 * quotes are stripped and quoted-pair sequences (`\\X`) are unescaped per
157 * RFC 9110 §5.6.4. */
158function 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
166function parseNonNegativeInt(value: string, directive: string): number {
167 const trimmed = unquoteArgument(value);

Callers 2

parseNonNegativeIntFunction · 0.85
parseFieldNamesFunction · 0.85

Calls 2

startsWithMethod · 0.80
sliceMethod · 0.45

Tested by

no test coverage detected