Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

when cookie path === null dont default it

  • Loading branch information...
commit ee4471b345d3a8f7622d16ea064e97e1f63d9c1e 1 parent 6815feb
@tj tj authored
Showing with 20 additions and 1 deletion.
  1. +1 −1  lib/response.js
  2. +19 −0 test/response.test.js
View
2  lib/response.js
@@ -322,7 +322,7 @@ res.clearCookie = function(name, options){
res.cookie = function(name, val, options){
options = options || {};
if ('maxAge' in options) options.expires = new Date(Date.now() + options.maxAge);
- options.path = options.path || this.app.set('home');
+ if (undefined === options.path) options.path = this.app.set('home');
var cookie = utils.serializeCookie(name, val, options);
this.header('Set-Cookie', cookie);
};
View
19 test/response.test.js
@@ -650,6 +650,25 @@ module.exports = {
});
},
+ 'test #cookie() null path': function(){
+ var app = express.createServer();
+
+ app.set('/home', '/foo');
+
+ app.get('/', function(req, res){
+ res.cookie('rememberme', 'yes', { path: null, expires: new Date(1), httpOnly: true });
+ res.cookie('something', 'else', { path: null });
+ res.redirect('/');
+ });
+
+ assert.response(app,
+ { url: '/', headers: { Host: 'foo.com' }},
+ function(res){
+ res.headers['set-cookie']
+ .should.eql(['rememberme=yes; expires=Thu, 01 Jan 1970 00:00:00 GMT; httpOnly', 'something=else']);
+ });
+ },
+
'test #clearCookie() default path': function(){
var app = express.createServer();
Please sign in to comment.
Something went wrong with that request. Please try again.