Skip to content
Myr

Merge pull request #1458 from gmethvin/cookie_options

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Don't mangle the options object in res.cookie

authored by TJ Holowaychuk · committed by TJ Holowaychuk · parents 8d21f1e, 39ee6f8 · Browse files · 2 files+25 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+25 added−3 removed

  • tests:+20 added−0 removed
  • other:+5 added−3 removed

2 files+25 added−3 removed

modified:lib/response.js+5 added-3 removed
571 unmodified lines
572 * @api public573 */574575res.cookie = function(name, val, options){576 options = options || {};576 options = utils.merge({}, options);577 var secret = this.req.secret;578 var signed = options.signed;579 if (signed && !secret) throw new Error('connect.cookieParser("secret") required for signed cookies');580 if ('object' == typeof val) val = 'j:' + JSON.stringify(val);581 if (signed) val = 's:' + sign(val, secret);582 if ('maxAge' in options) options.expires = new Date(Date.now() + options.maxAge);582 if ('maxAge' in options) {583 options.expires = new Date(Date.now() + options.maxAge);584 options.maxAge /= 1000;585 }586 if (null == options.path) options.path = '/';584 options.maxAge /= 1000;587 this.set('Set-Cookie', cookie.serialize(name, String(val), options));588 return this;589};590
132 unmodified lines
modified:test/res.cookie.js+20 added