Skip to content

fix(serve-static): respect q-values in Accept-Encoding for precompressed files - #5436

Merged
yusukebe merged 1 commit into
honojs:mainfrom
otnc:fix/serve-static-precompressed-accept-encoding-qvalue
Oct 16, 2026
Merged

yusukebe merged 1 commit into
honojs:mainfrom
otnc:fix/serve-static-precompressed-accept-encoding-qvalue

Conversation

@otnc

@otnc otnc commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

With precompressed: true, serveStatic splits Accept-Encoding on commas and compares the raw tokens. An encoding sent with a q-value, such as gzip;q=1.0, never matches, so the uncompressed file is served even when a precompressed one exists.

This parses the header with parseAccept, as the compress middleware does, and skips encodings rejected with q=0. The preference order (br > zstd > gzip) is unchanged.

The author should do the following, if applicable

  • Add tests
  • Run tests
  • pnpm run format:fix && pnpm run lint:fix to format the code
  • Add TSDoc/JSDoc to document the code

@codecov

codecov Bot commented Oct 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.34%. Comparing base (8dcd52b) to head (c99c8bd).
⚠️ Report is 53 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5436      +/-   ##
==========================================
- Coverage   80.05%   79.34%   -0.71%     
==========================================
  Files         156      156              
  Lines       11094    11199     +105     
  Branches     2377     2378       +1     
==========================================
+ Hits         8881     8886       +5     
- Misses       2213     2313     +100     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yusukebe yusukebe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@yusukebe

Copy link
Copy Markdown
Member

@otnc

Nice fix. Thanks.

@yusukebe
yusukebe merged commit d54720d into honojs:main Oct 16, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants