Skip to content

Commit a6ad7ea

Browse files
committed
res.clearCookie now ignores maxAge. fixes expressjs#4851
1 parent e8594c3 commit a6ad7ea

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/response.js

+1
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,7 @@ res.get = function(field){
805805

806806
res.clearCookie = function clearCookie(name, options) {
807807
var opts = merge({ expires: new Date(1), path: '/' }, options);
808+
delete opts.maxAge;
808809

809810
return this.cookie(name, '', opts);
810811
};

test/res.clearCookie.js

+13
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,18 @@ describe('res', function(){
3232
.expect('Set-Cookie', 'sid=; Path=/admin; Expires=Thu, 01 Jan 1970 00:00:00 GMT')
3333
.expect(200, done)
3434
})
35+
36+
it('should ignore maxAge', function(done){
37+
var app = express();
38+
39+
app.use(function(req, res){
40+
res.clearCookie('sid', { path: '/admin', maxAge: 900 }).end();
41+
});
42+
43+
request(app)
44+
.get('/')
45+
.expect('Set-Cookie', 'sid=; Path=/admin; Expires=Thu, 01 Jan 1970 00:00:00 GMT')
46+
.expect(200, done)
47+
})
3548
})
3649
})

0 commit comments

Comments
 (0)