mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #403] [MERGED] fix: RequestCookie behavior and getAll(name) #546
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#546
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/403
Author: @JaredStowell
Created: 3/10/2026
Status: ✅ Merged
Merged: 3/10/2026
Merged by: @james-elicx
Base:
main← Head:jstowell/fix-request-cookies-parity📝 Commits (3)
686c254Verify cookie header parsingd9d125aFix empty cookie handlingf21030cFix empty cookie parsing fallback📊 Changes
4 files changed (+281 additions, -27 deletions)
View changed files
📝
packages/vinext/src/shims/headers.ts(+11 -15)➕
packages/vinext/src/shims/internal/parse-cookie-header.ts(+32 -0)📝
packages/vinext/src/shims/server.ts(+7 -12)📝
tests/shims.test.ts(+231 -0)📄 Description
Align vinext request-cookie behavior with the current Next.js runtime in both request-cookie implementations:
packages/vinext/src/shims/headers.tspackages/vinext/src/shims/server.tsWhat changed
Fix
RequestCookies.getAll(name)getAll(name)was ignoring its argument and returning the full cookie list.Before, with:
vinext returned:
get('a') => { name: 'a', value: '2' }getAll('a') => [{ name: 'a', value: '2' }, { name: 'b', value: '3' }]Now it returns:
get('a') => { name: 'a', value: '2' }getAll('a') => [{ name: 'a', value: '2' }]This now works for both overloads:
getAll("a")getAll({ name: "a" })Missing names now correctly return
[].Align request cookie parsing with current Next.js runtime
While expanding coverage, I found both request-cookie parsers also diverged from current Next.js runtime behavior.
Both shims now match
next@16.1.6for:"true"Examples:
token=abc%3D123=>abc=123bad=%E0%A4%A=> skippedflag=>{ name: "flag", value: "true" }Keep middleware cookie rewrites consistent
applyMiddlewareRequestHeaders()now rebuilds the cookie map using the same parser, so middleware-rewrittencookieheaders behave the same as initially parsed request headers.Tests
Added targeted regressions in
tests/shims.test.tscovering:getAll("name")getAll({ name })🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.