Skip to content

Commit

Permalink
perf: normalize secret argument only once
Browse files Browse the repository at this point in the history
closes #46
  • Loading branch information
oliviertassinari authored and dougwilson committed Dec 20, 2018
1 parent 49aca50 commit 7ea8ab3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
unreleased
==========

* perf: normalize `secret` argument only once

1.4.3 / 2016-05-26
==================

Expand Down
7 changes: 4 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,16 @@ module.exports.signedCookies = signedCookies
*/

function cookieParser (secret, options) {
var secrets = !secret || Array.isArray(secret)
? (secret || [])
: [secret]

return function cookieParser (req, res, next) {
if (req.cookies) {
return next()
}

var cookies = req.headers.cookie
var secrets = !secret || Array.isArray(secret)
? (secret || [])
: [secret]

req.secret = secrets[0]
req.cookies = Object.create(null)
Expand Down

0 comments on commit 7ea8ab3

Please sign in to comment.