-
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't send the
Set-Cookie
header multiple times for the same cookie (…
…#237) * use set to update header * update tests * Revert "update tests" and add a new one This reverts commit f69221b. * use symbol * use a Map and onSend hook * add back line * nit: remove variable and change separator * unwrap fastifyCookieOnSendHandler * Use || instead of ?? * make it compatible with header() * move tap test path to taprc * use values * add examples * istanbul ignore else * remove signCookie decorator * remove types * Revert "remove signCookie decorator" This reverts commit eddf349. * Revert "remove types" This reverts commit 1fbca3c. * no need to pass signer to fastifyCookieSetCookie * add type and tests for serializeCookie * remove once-used const * add type to serializeCookie options * move interface * remove examples * move encode to seralize options * fast path * don't use for * use for...of * add benchmarks * use undefined
- Loading branch information
Showing
8 changed files
with
302 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
100: true | ||
check-coverage: true | ||
coverage: true | ||
files: | ||
- test/**/*.test.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict' | ||
|
||
const Fastify = require('fastify') | ||
const plugin = require('../') | ||
|
||
const secret = 'testsecret' | ||
|
||
const fastify = Fastify() | ||
fastify.register(plugin, { secret }) | ||
|
||
fastify.get('/', (req, reply) => { | ||
reply | ||
.setCookie('foo', 'foo') | ||
.setCookie('foo', 'foo', { path: '/1' }) | ||
.setCookie('boo', 'boo', { path: '/' }) | ||
.setCookie('foo', 'foo-different', { path: '/' }) | ||
.setCookie('foo', 'foo', { path: '/2' }) | ||
.send({ hello: 'world' }) | ||
}) | ||
|
||
fastify.listen({ host: '127.0.0.1', port: 5001 }, (err, address) => { | ||
if (err) throw err | ||
console.log(address) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use strict' | ||
|
||
const Fastify = require('fastify') | ||
const plugin = require('../') | ||
|
||
const secret = 'testsecret' | ||
|
||
const fastify = Fastify() | ||
fastify.register(plugin, { secret }) | ||
|
||
fastify.get('/', (req, reply) => { | ||
reply | ||
.setCookie('foo', 'foo', { path: '/' }) | ||
.send({ hello: 'world' }) | ||
}) | ||
|
||
fastify.listen({ host: '127.0.0.1', port: 5001 }, (err, address) => { | ||
if (err) throw err | ||
console.log(address) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.