Skip to content

Commit 7e12b68

Browse files
committed
Fix Infinity validation in addDaysToDateKey
The function only checked for NaN, not Infinity. If the date string represented an extreme date, getTime() could return Infinity, causing the date arithmetic to produce invalid results. Changed Number.isNaN() to Number.isFinite() to catch both NaN and Infinity.
1 parent 7b65652 commit 7e12b68

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

common/src/util/freebuff-streak.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export function getFreebuffUsageDateKey(
4848

4949
export function addDaysToDateKey(dateKey: string, days: number): string {
5050
const date = new Date(`${dateKey}T00:00:00.000Z`)
51-
if (Number.isNaN(date.getTime())) {
51+
if (!Number.isFinite(date.getTime())) {
5252
throw new Error(`Invalid date key: ${dateKey}`)
5353
}
5454

0 commit comments

Comments
 (0)