You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I happened across this by chance, but it's a very real scenario for me in a production application. Moment.js, when passed a specific UUID, believes it to be a date. (presumably other UUIDs are mistaken for dates as well, but this was the one I happened across)
Here's an example;
> moment('5917238b-33ff-f849-cd63-80f4c9b37d0c').toDate()
< Sun Aug 26 5917 00:00:00 GMT-0500 (CDT)
> moment('5917238b-33ff-f849-cd63-80f4c9b37d0c').isValid()
< true
Compare that with just about any other UUID, and the result is what I'd expect;
> moment('5e7af008-b108-40bb-ae8d-50ea223a8219').toDate()
< Invalid Date
> moment('5e7af008-b108-40bb-ae8d-50ea223a8219').isValid()
< false
From an expectation standpoint, I'd expect all UUIDs to return false for isValid. The erroneous condition actually causes my application to run with the date Aug. 26 5917, as it assumed the user was trying to input a date 😮
I've confirmed this behavior in both 2.11.0 running on Node.js, and 2.11.2 running in Chrome - same behavior in both platforms.
The text was updated successfully, but these errors were encountered:
This means that the dates you are passing in must exactly match an ISO8601 format, which may not be the case for your application. You might also consider multiple format parsing with strict mode, if you have multiple known formats but they can be enumerated:
The behavior that you are seeing is actually already documented as a bug in #2985. I know this looks dissimilar, but both issues boil down to the characters after the matched regular expression being ignored.
I'm going to close this issue since it matches the other bug, but feel free to let us know if you need more help with making things work.
I happened across this by chance, but it's a very real scenario for me in a production application. Moment.js, when passed a specific UUID, believes it to be a date. (presumably other UUIDs are mistaken for dates as well, but this was the one I happened across)
Here's an example;
Compare that with just about any other UUID, and the result is what I'd expect;
From an expectation standpoint, I'd expect all UUIDs to return
false
forisValid
. The erroneous condition actually causes my application to run with the date Aug. 26 5917, as it assumed the user was trying to input a date 😮I've confirmed this behavior in both 2.11.0 running on Node.js, and 2.11.2 running in Chrome - same behavior in both platforms.
The text was updated successfully, but these errors were encountered: