Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the parseHttpDate function to improve performance and correctness by adding JSDoc documentation, implementing weekday validation, and updating RFC850 year parsing to comply with RFC 6265.
- Replaces string-based parsing with character code validation for better performance
- Adds weekday validation to ensure dates match their specified day of the week
- Updates RFC850 two-digit year handling according to RFC 6265 (70-99 → 1970-1999, 00-69 → 2000-2069)
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| lib/util/date.js | Complete rewrite of date parsing functions with character-level validation and weekday checking |
| test/utils/date.js | Extensive test additions including fuzzing tests and corrected weekday values in existing tests |
| benchmarks/utils/date.mjs | New benchmark file for performance testing the parseHttpDate function |
| benchmarks/package.json | Added tinybench dependency for benchmarking |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Merged
slagiewka
pushed a commit
to slagiewka/undici
that referenced
this pull request
Feb 14, 2026
* chore: improve util/date * add benchmark * case sensitive * improve mainly asctime * take care of other cases * remove one check * add fuzzing * remove redundant line * add test from http-dates * add weekday check, adapt rfc 6265 for interpretation of rfc850 * fix ascTime * remove unused parameter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR modifies the parseHttpDate function by adding jsdoc, and doing two major changes:
At one point i took the unit tests of the npm package http-dates, which tests for the correct weekday, but it doesnt convince me personally. We can of course remove the weekday check.
The rfc850 year logic is imho more important.
Also it increases the performance significantly.
before:
after:
This relates to...
Rationale
Changes
Features
Bug Fixes
Breaking Changes and Deprecations
Status