Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 15x 15x 15x 15x 15x 212x 10x 212x 12x 3x 9x 212x 212x 212x | /**
* Parses a Retry-After header value: delta seconds ("30") or an HTTP date.
* Returns milliseconds, or undefined when absent or malformed.
*/
export function parseRetryAfter(value, now) {
if (value === null || value === undefined) return undefined;
const s = String(value).trim();
if (!s) return undefined;
if (/^\d+$/.test(s)) return parseInt(s, 10) * 1000;
const t = Date.parse(s);
if (isNaN(t)) return undefined;
const ref = typeof now === 'number' ? now : Date.now();
return Math.max(0, t - ref);
}
|