fix: remove cookies that expire at epoch time of 0 by colincasey · Pull Request #457 · salesforce/tough-cookie (original) (raw)
The logic for checking and removing expired cookies fails when the cookie has an expiry date set to the epoch time of 0 (i.e.; Thu, 01 Jan 1970 00:00:00 GMT). This is because the branch check that triggers cookie removal was testing expiryTime which is falsy for a value of 0 and that short-circuits the logic.
This PR updates the logic to narrow the type of expiryTime from number | undefined to number using expiryTime != undefined which allows the 0 value to proceed to the subsequent condition and trigger the cookie removal.
Fixes #455