Skip to content

docs: handle a missing Authorization header in README examples - #108

Merged
blakeembrey merged 2 commits into
jshttp:masterfrom
ucsurf:docs-readme-parse-missing-header
Oct 7, 2026
Merged

blakeembrey merged 2 commits into
jshttp:masterfrom
ucsurf:docs-readme-parse-missing-header

Conversation

@ucsurf

@ucsurf ucsurf commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Thanks for the invite to send this.

In v3, parse() expects a string, so the README examples now pass req.headers.authorization ?? '', matching the upgrade instructions. That way a request without an Authorization header gets undefined back (and a 401 in the http server example) instead of throwing.

Docs only; no code changes.

Comment thread README.md Outdated

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.

Suggested change
const user = parse(req.getHeader('Proxy-Authorization') ?? '');

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Applied, thanks!

@blakeembrey

Copy link
Copy Markdown
Member

Awesome, thanks! I think in a real scenario a ternary (e.g. skipping parse entirely) might be warranted, this is perfect for example code 🙏

@blakeembrey
blakeembrey merged commit 301fe41 into jshttp:master Oct 7, 2026
7 checks passed
@codecov

codecov Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (0ea09f3) to head (7fc82f7).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #108   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines           38        38           
  Branches        10        10           
=========================================
  Hits            38        38           

☔ 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.

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