-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PM-11588] Bugfix - parse user input value for combined expiry date w…
…hen creating/adding a card cipher (#11103) * simplify logic and fix some pattern-matching bugs * add first pass at parsing combined expiry year and month from user input * clean up code * fix broken three-digit parsing case * fix case where splitCombinedDateValues returns empty strings when the input is only a delimiter * fix incorrect expectation of falsy negative integers * clean up code * split out logic from parseYearMonthExpiry * move utils from vault to autofill
- Loading branch information
Showing
16 changed files
with
648 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
export const CardExpiryDateDelimiters: string[] = ["/", "-", ".", " "]; | ||
|
||
// `CardExpiryDateDelimiters` is not intended solely for regex consumption, | ||
// so we need to format it here | ||
export const ExpiryDateDelimitersPattern = | ||
"\\" + | ||
CardExpiryDateDelimiters.join("\\") | ||
// replace space character with the regex whitespace character class | ||
.replace(" ", "s"); | ||
|
||
export const MonthPattern = "(([1]{1}[0-2]{1})|(0?[1-9]{1}))"; | ||
|
||
// Because we're dealing with expiry dates, we assume the year will be in current or next century (as of 2024) | ||
export const ExpiryFullYearPattern = "2[0-1]{1}\\d{2}"; | ||
|
||
export const DelimiterPatternExpression = new RegExp(`[${ExpiryDateDelimitersPattern}]`, "g"); | ||
|
||
export const IrrelevantExpiryCharactersPatternExpression = new RegExp( | ||
// "nor digits" to ensure numbers are removed from guidance pattern, which aren't covered by ^\w | ||
`[^\\d${ExpiryDateDelimitersPattern}]`, | ||
"g", | ||
); | ||
|
||
export const MonthPatternExpression = new RegExp(`^${MonthPattern}$`); | ||
|
||
export const ExpiryFullYearPatternExpression = new RegExp(`^${ExpiryFullYearPattern}$`); |
Oops, something went wrong.