fixed bug in the masked number for credit card.

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-06-07 17:19:51 -05:00
parent 19b102348c
commit 15b7e9be62

View File

@ -254,7 +254,7 @@ extension InputField {
let rawNumber = number.filter { $0.isNumber }
guard rawNumber.count == cardType.maxLength else { return formatCreditCardNumber(cardType, number: number) }
let lastFourDigits = rawNumber.suffix(4)
let maskedSection = String(repeating: "", count: 12)
let maskedSection = String(repeating: "", count: number.count - lastFourDigits.count)
let formattedMaskSection = String.format(maskedSection, indices: cardType.separatorIndices(rawNumber.count), with: " ")
return formattedMaskSection + " " + lastFourDigits
}