Fix Date Validation in chunkDaysIntoWeeks Function - #8876
Conversation
|
This PR enhances the date validation logic by replacing the previous loose regex and new Date() checks with explicit validation for date components. This change is crucial as it prevents garbage dates from polluting the contribution calendar data, aligning with our previous decisions on improving date validation. Thank you for your contribution! |
📦 Next.js Bundle Size Report (Gzipped Sizes)✨ No significant bundle size changes detected. 📊 Summary of Totals
|
Aamod007
left a comment
There was a problem hiding this comment.
Excellent work on this date validation fix! Using explicit matching and checking the \daysInMonth\ ensures that impossible dates like 2024-02-30 are properly rejected, avoiding bad data from sneaking into the contribution calendar. The transition from a loose regex and generic
ew Date\ to strict validation in \lib/calculate.ts\ is exactly what's needed. Approved!
Summary of What Has Been Done
Replaced the loose regex +
new Date()validity check with explicit date component validation. The fix validates that month is 1-12 and uses a days-in-month lookup to reject impossible dates like "2024-02-30".Changes Made
lib/calculate.ts: Added explicit date component validationImpact it Made
Closes #8844
Note: Please assign this PR to the
tmdeveloper007account.