Skip to content

feat: support all 16 IANA-registered Cache-Control directives#388

Merged
tusbar merged 1 commit intomasterfrom
tusbar/modernize
Feb 17, 2026
Merged

feat: support all 16 IANA-registered Cache-Control directives#388
tusbar merged 1 commit intomasterfrom
tusbar/modernize

Conversation

@tusbar
Copy link
Owner

@tusbar tusbar commented Feb 17, 2026

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

@codecov
Copy link

codecov bot commented Feb 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (e9d594e) to head (b938fe1).
⚠️ Report is 4 commits behind head on master.
✅ All tests successful. No failed tests found.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tusbar tusbar force-pushed the tusbar/modernize branch 2 times, most recently from cae4ce6 to 909c230 Compare February 17, 2026 12:57
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-understand plus qualified no-cache / private field-name lists (noCacheFields, privateFields).
  • Refactor parsing to use matchAll and 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.

@tusbar tusbar force-pushed the tusbar/modernize branch 2 times, most recently from baa6c0f to 25206f1 Compare February 17, 2026 13:09
@tusbar tusbar requested a review from Copilot February 17, 2026 13:09
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@tusbar tusbar merged commit 5512b86 into master Feb 17, 2026
6 checks passed
@tusbar tusbar deleted the tusbar/modernize branch February 17, 2026 13:34
@tusbar
Copy link
Owner Author

tusbar commented Feb 17, 2026

🎉 This PR is included in version 3.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add references to RFC Support header lists

2 participants