Closed robinbraemer closed 1 year ago
You need to pass a Date
object for the expires
option, not a string. Parsing a string into a Date
object is an operation you need to do before calling this module. This is not a bug and accepting a string and trying to parse it is not really something that will be added here, I'm sorry. You need to parse into a Date
object according to your needs before calling this module.
Problem: When I was working with AuthJS, your 'cookie' module currently throws an error when the 'expires' option is provided in a non-standard date format, such as "2023-11-26T09:50:03.088Z." This error limits the flexibility of date handling in the module.
I printed what
opt.expires
would be, and the second 'it me' is the one AuthJS provides, to my understanding:Solution: This PR updates the code to handle a broader range of date formats for the 'expires' option by using the JavaScript
Date
constructor for parsing.Testing: I tested that the changes support previous edge cases and my case format that previously caused an error.
Additional Notes: This change doesn't impact other functionality and maintains compatibility with existing code while enhancing date format flexibility.
Your feedback on this fix is appreciated. Thank you for reviewing the PR.