Skip to content

feat: implements injected cookies encoding respecting http state management rfc - #401

Open
big-kahuna-burger wants to merge 1 commit into
fastify:mainfrom
big-kahuna-burger:feat/cookies
Open

feat: implements injected cookies encoding respecting http state management rfc#401
big-kahuna-burger wants to merge 1 commit into
fastify:mainfrom
big-kahuna-burger:feat/cookies

Conversation

@big-kahuna-burger

@big-kahuna-burger big-kahuna-burger commented Aug 22, 2026

Copy link
Copy Markdown

Summary

  • inject({ cookies }) now encodes cookies onto the Cookie header using RFC 6265 §5.1.4 path matching, so a cookie with Path=/account/123 is not sent to /account/other.
  • Accepts the existing name: value map (no path → treated as Path=/), name: { value, path } records, or a previous res.cookies array.
  • Docs live in docs/cookies.md (so I don't pollute a nice readme with extra hunk related to cookies only); the generated lib/config-validator.js allows a cookie array as well as an object.

Test plan

  • npm test (lint, 100% unit coverage, tstyche)
  • Confirm string cookies still go out on every path: { session: 'abc' }
  • Confirm a scoped cookie is omitted when the request path does not match
  • Confirm a scoped cookie is sent when the request path is a valid RFC 6265 prefix (/account/123/account/123/settings, not /account/other or /docsets vs /docs)
  • Replay login.cookies onto a later inject and check only matching cookies appear on Cookie

Checklist

@mcollina mcollina 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

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