[React-Native] cannot parse expires
returns Invalid Date for Expires=Thu, 26-Mar-2020 07:55:35 GMT as an example
Oh boy. I guess that's what I get for using the built in Date parser. I suspect it's choking on the dashes in 26-Mar-2020. Amusingly, Firefox mis-interprets them as negatives:
new Date('Thu, 26-Mar-2020 07:55:35 GMT')
//> Date Wed Mar 26 -2020 02:59:33 GMT-0456 (Eastern Standard Time)
Chrome and, by extension, Node.js handle it correctly. As does Safari on mac (13.0.5) and in the iOS simulator (13.2.2). I kind of expected/hoped Safari would give the same error you were getting so that I could at least have a straightforward way or reproducing & testing it :(
Do you know much about automated testing for React Native? If you could make me a test-case that reproduces the error? That would help.
For context, here is the official algorithm for how to parse the expires field: https://tools.ietf.org/html/rfc6265#section-5.1.1 - using the Date object was just a convenient hack that seemed to work well enough until now. I'm not entirely against implementing it, although I'm a little divided as to weather or not it should be the default.
It seems that replacing the dashes with slashes could work https://stackoverflow.com/questions/8831338/date-issue-in-firefox/8831539
Note to self: tough-cookie has a spec-compliant parser: https://github.com/salesforce/tough-cookie/blob/v4.1.3/lib/cookie.js#L193
(apparently moving to here for the next version: https://github.com/salesforce/tough-cookie/blob/master/lib/cookie/parseDate.ts