Skip to content

Commit

Permalink
rename variables
Browse files Browse the repository at this point in the history
  • Loading branch information
gurgunday committed Jan 12, 2024
1 parent acf2a05 commit 0479a09
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ function onReqHandlerWrapper (fastify, hook) {
}

function setCookies (reply) {
const setCookieHeader = reply.getHeader('Set-Cookie')
let setCookie
const setCookieHeaderValue = reply.getHeader('Set-Cookie')
let cookieValue

if (setCookieHeader === undefined) {
if (setCookieHeaderValue === undefined) {
if (reply[kReplySetCookies].size === 1) {
// Fast path for single cookie
const c = reply[kReplySetCookies].values().next().value
Expand All @@ -82,19 +82,19 @@ function setCookies (reply) {
return
}

setCookie = []
} else if (typeof setCookieHeader === 'string') {
setCookie = [setCookieHeader]
cookieValue = []
} else if (typeof setCookieHeaderValue === 'string') {
cookieValue = [setCookieHeaderValue]
} else {
setCookie = setCookieHeader
cookieValue = setCookieHeaderValue
}

for (const c of reply[kReplySetCookies].values()) {
setCookie.push(cookie.serialize(c.name, c.value, c.opts))
cookieValue.push(cookie.serialize(c.name, c.value, c.opts))
}

reply.removeHeader('Set-Cookie')
reply.header('Set-Cookie', setCookie)
reply.header('Set-Cookie', cookieValue)
reply[kReplySetCookies].clear()
}

Expand Down

0 comments on commit 0479a09

Please sign in to comment.