fix(cookie): support encode option#1899
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughCookie value encoding is now configurable via an optional ChangesCookie Encoding Support
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
src/dynamic-handle.tsOops! Something went wrong! :( ESLint: 9.39.4 Error: ESLint configuration in --config » plugin:sonarjs/recommended is invalid:
Referenced from: /.eslintrc.json ... [truncated 291 characters] ... /node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2952:16) test/cookie/response.test.tsOops! Something went wrong! :( ESLint: 9.39.4 Error: ESLint configuration in --config » plugin:sonarjs/recommended is invalid:
Referenced from: /.eslintrc.json ... [truncated 291 characters] ... /node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2952:16) Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/dynamic-handle.ts`:
- Around line 479-481: The current precedence for cookie encoder flips
route-level overrides because encode uses app.config.cookie?.encode ??
routeCookieConfig?.encode; change this to prefer the route encoder by using
routeCookieConfig?.encode ?? app.config.cookie?.encode in the same assignment
block (where encode, secrets, sign are set), and add a regression test that sets
both an app-level encoder and a route-level encoder to assert the route-level
encoder is used in dynamic mode.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 0fdd09b1-7385-47d2-bda0-45b63c89b73e
📒 Files selected for processing (5)
src/compose.tssrc/cookies.tssrc/dynamic-handle.tssrc/type-system/index.tstest/cookie/response.test.ts
Summary
encodeon cookie options and cookie instancesencodeinto cookie parsing/serialization in both AOT and dynamic handlerst.Cookie(..., { encode })config in dynamic modeFixes #1698
Reproduction
Before this change, a custom cookie encoder was ignored and the response emitted
name=seminar%20Himari; Path=/:The expected header is
name=seminar+Himari; Path=/.Boundary report
Covered cases:
t.Cookie(..., { encode })in AOT modet.Cookie(..., { encode })in dynamic modecookie.name.encode = ...Tests
bun test test/cookie/response.test.tsbun test test/cookiebun test test/validator/cookie.test.tsbun run test:typesbun testbun run test:importsSummary by CodeRabbit
New Features
Tests