Skip to content

Fix Infinity validation in addDaysToDateKey - #1252

Open
pavankumar-vh wants to merge 1 commit into
CodebuffAI:mainfrom
pavankumar-vh:fix/add-days-date-infinity-validation
Open

Fix Infinity validation in addDaysToDateKey#1252
pavankumar-vh wants to merge 1 commit into
CodebuffAI:mainfrom
pavankumar-vh:fix/add-days-date-infinity-validation

Conversation

@pavankumar-vh

Copy link
Copy Markdown

Overview

Fix Infinity validation in the addDaysToDateKey function in common/src/util/freebuff-streak.ts.

Bug Description

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.

Fix

Changed Number.isNaN() to Number.isFinite() to catch both NaN and Infinity.

Testing

No existing tests for this function, but the fix prevents incorrect behavior with extreme dates.

Files Changed

  • common/src/util/freebuff-streak.ts - Added Infinity validation

Scope

This change only touches common/ which is an approved contribution area per the Contributing Guide.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant