feat: support all 16 IANA-registered Cache-Control directives#388
feat: support all 16 IANA-registered Cache-Control directives#388
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #388 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 1 1
Lines 99 114 +15
Branches 23 17 -6
=========================================
+ Hits 99 114 +15 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
cae4ce6 to
909c230
Compare
There was a problem hiding this comment.
Pull request overview
This PR extends the Cache-Control parser/formatter to cover additional RFC 9111 directives and qualified forms, aligning behavior with IANA-registered directives and fixing previously incorrect parsing for no-cache/private when field-name arguments are present.
Changes:
- Add support for
must-understandplus qualifiedno-cache/privatefield-name lists (noCacheFields,privateFields). - Refactor parsing to use
matchAlland refactor formatting via helper functions. - Expand test coverage for edge cases and update README/package keywords with RFC references.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
src/index.ts |
Adds new directive fields, updates parsing logic for qualified directives, and refactors formatting helpers. |
__tests__/index.spec.ts |
Adds tests for new directives, qualified field-name handling, and robustness edge cases. |
README.md |
Documents supported directives, qualified directives, and updates usage examples/RFC references. |
package.json |
Adds RFC-related keywords for discoverability. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
baa6c0f to
25206f1
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add must-understand directive (RFC 9111 §5.2.2.3), qualified forms for no-cache and private with field-name lists (RFC 9111 §5.2.2.4, §5.2.2.7), and edge case tests for malformed headers. - Add mustUnderstand boolean property - Add noCacheFields and privateFields string array properties - Fix no-cache="Set-Cookie" incorrectly parsed as noCache: false - Fix private="Set-Cookie" incorrectly parsed as private: false - Refactor parser to use matchAll for proper quoted-value extraction - Extract format helpers to reduce complexity - Add robustness tests (unclosed quotes, negative/huge durations, etc.) - Update README with full directive tables and RFC references - Update keywords to reference RFC 9111, RFC 8246, RFC 5861 - Validate field names against RFC 9110 token grammar when formatting - Add JSDoc documentation to exported symbols BREAKING CHANGE: `noCache` and `private` now correctly return `true` when the directive is present with field-name arguments (e.g. `no-cache="Set-Cookie"`). Previously these were incorrectly parsed as `false`, silently dropping the directive. Closes #2 Closes #3
25206f1 to
b938fe1
Compare
|
🎉 This PR is included in version 3.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Add must-understand directive (RFC 9111 §5.2.2.3), qualified forms for no-cache and private with field-name lists (RFC 9111 §5.2.2.4, §5.2.2.7), and edge case tests for malformed headers.
BREAKING CHANGE:
noCacheandprivatenow correctly returntruewhen the directive is present with field-name arguments (e.g.no-cache="Set-Cookie"). Previously these were incorrectly parsed asfalse, silently dropping the directive.Closes #2
Closes #3