Skip to content

Commit

Permalink
fix consistency with uncertain cases in isCardExpired
Browse files Browse the repository at this point in the history
  • Loading branch information
jprusik committed Jan 2, 2025
1 parent 5bf2e4d commit 85c2b1d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion libs/common/src/autofill/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function getCardExpiryDateValues() {
[undefined, undefined, false], // no month, no year, invalid values
["", "", false], // no month, no year, invalid values
["12", "agdredg42grg35grrr. ea3534@#^145345ag$%^ -_#$rdg ", false], // invalid values
["0", `${currentYear}`, true], // invalid month
["0", `${currentYear}`, false], // invalid month
["0", `${currentYear - 1}`, true], // invalid 0 month
["00", `${currentYear + 1}`, false], // invalid 0 month
[`${currentMonth}`, "0000", true], // current month, in the year 2000
Expand Down
6 changes: 3 additions & 3 deletions libs/common/src/autofill/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function normalizeExpiryYearFormat(yearInput: string | number): Year | nu

/**
* Takes a cipher card view and returns "true" if the month and year affirmativey indicate
* the card is expired. Uncertain cases return "false"
* the card is expired. Uncertain cases return "false".
*
* @param {CardView} cipherCard
* @return {*} {boolean}
Expand Down Expand Up @@ -85,9 +85,9 @@ export function isCardExpired(cipherCard: CardView): boolean {
const parsedMonthInteger = parseInt(expMonth, 10);
const parsedMonthIsValid = parsedMonthInteger && !isNaN(parsedMonthInteger);

// If the parsed month value is 0, we don't know when the expiry passes this year, so treat it as expired
// If the parsed month value is 0, we don't know when the expiry passes this year, so do not treat it as expired
if (!parsedMonthIsValid) {
return true;
return false;
}

// `Date` months are zero-indexed
Expand Down

0 comments on commit 85c2b1d

Please sign in to comment.