* Parse HTTP-date format (RFC 7231).
(value: string)
| 188 | * Parse HTTP-date format (RFC 7231). |
| 189 | */ |
| 190 | function parseHttpDate(value: string): number | null { |
| 191 | const timestamp = Date.parse(value); |
| 192 | if (!isNaN(timestamp)) { |
| 193 | // Sanity check: within reasonable range (not too far past or future) |
| 194 | const now = Date.now(); |
| 195 | const oneYearMs = 365 * 24 * 60 * 60 * 1000; |
| 196 | if (timestamp > now - oneYearMs && timestamp < now + oneYearMs) { |
| 197 | return timestamp; |
| 198 | } |
| 199 | } |
| 200 | return null; |
| 201 | } |
| 202 | |
| 203 | /** |
| 204 | * Parse duration strings like "1s", "100ms", "1m30s", "1h30s", "2h15m30s". |
no test coverage detected
searching dependent graphs…