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

Function parseNonNegativeInt

http/unstable_cache_control.ts:166–175  ·  view source on GitHub ↗
(value: string, directive: string)

Source from the content-addressed store, hash-verified

164}
165
166function parseNonNegativeInt(value: string, directive: string): number {
167 const trimmed = unquoteArgument(value);
168 if (!DIGITS_REGEXP.test(trimmed)) {
169 throw new SyntaxError(
170 `Cache-Control: invalid value for ${directive}: "${value}"`,
171 );
172 }
173 const n = Number(trimmed);
174 return n > MAX_DELTA_SECONDS ? MAX_DELTA_SECONDS : n;
175}
176
177/** Split by comma but not inside double-quoted strings, respecting RFC 9110
178 * §5.6.4 quoted-pairs. Needed for `no-cache` and `private` whose

Callers 1

parseCacheControlFunction · 0.85

Calls 1

unquoteArgumentFunction · 0.85

Tested by

no test coverage detected