Skip to content

Commit 5d7b2d9

Browse files
committed
fix: directives in cookies are joined by a semi-colon with a space
1 parent a140dc8 commit 5d7b2d9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

edge-runtime/lib/middleware.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ export function mergeMiddlewareCookies(middlewareResponse: Response, lambdaReque
7272
const regex = new RegExp(/,(?!\s)/)
7373

7474
middlewareCookies.split(regex).forEach((entry) => {
75-
const [cookie] = entry.split(';')
75+
// Extra directives within a cookie are joined on separated by "; "
76+
// See: https://github.com/vercel/next.js/blob/0edb1123066a010eff2aac274f948ca2c6e85c0f/packages/next/src/compiled/%40edge-runtime/cookies/index.js#L32-L47
77+
const [cookie] = entry.split('; ')
7678
const [name, value] = cookie.split('=')
7779
mergedCookies[name] = value
7880
})

0 commit comments

Comments
 (0)