Skip to content
Myr

[v4] Deprecate `res.clearCookie` accepting `options.maxAge` and `options.expires` (#5672)

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

* add deprecation notice for res.clearCookie maxAge/expires * update History.md for clearCookie deprecation change * add tests to codify deprecated behavior Co-authored-by: Chris de Almeida <ctcpip@users.noreply.github.com> ---------

authored by Jon Church · committed by GitHub · parent 689073d · Browse files · 3 files+42 added−0 removed
This commit

State

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

Trailers

  • Co-authored-by: Chris de Almeida <ctcpip@users.noreply.github.com>

Diff stats

3 files+42 added−0 removed

  • tests:+32 added−0 removed
  • other:+10 added−0 removed

3 files+42 added−0 removed

modified:lib/response.js+8 added
820 unmodified lines
821 * @public822 */823824res.clearCookie = function clearCookie(name, options) {825 if (options) {826 if (options.maxAge) {827 deprecate('res.clearCookie: Passing "options.maxAge" is deprecated. In v5.0.0 of Express, this option will be ignored, as res.clearCookie will automatically set cookies to expire immediately. Please update your code to omit this option.');828 }829 if (options.expires) {830 deprecate('res.clearCookie: Passing "options.expires" is deprecated. In v5.0.0 of Express, this option will be ignored, as res.clearCookie will automatically set cookies to expire immediately. Please update your code to omit this option.');831 }832 }833 var opts = merge({ expires: new Date(1), path: '/' }, options);834835 return this.cookie(name, '', opts);836};
342 unmodified lines
modified:test/res.clearCookie.js+32 added
modified:History.md+2 added
1 unmodified line
2==========34 * deps: encodeurl@~2.0.05 - Removes encoding of `\`, `|`, and `^` to align better with URL spec6 * Deprecate passing `options.maxAge` and `options.expires` to `res.clearCookie`7 - Will be ignored in v5, clearCookie will set a cookie with an expires in the past to instruct clients to delete the cookie894.19.2 / 2024-03-2510==========11
3612 unmodified lines