1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 08:43:33 +00:00

[PM-11350] Use shared expiration year normalization util function (#10735)

* use shared expiration year normalization util function

* use shared exp year normalization in web and desktop client

* handle cases where input has leading zeroes

* add utils tests

* handle cases where input is all zeroes
This commit is contained in:
Jonathan Prusik
2024-09-03 15:12:36 -04:00
committed by GitHub
parent b27dc44298
commit 5f2eecd7be
8 changed files with 142 additions and 12 deletions

View File

@@ -7,6 +7,7 @@ import { JslibModule } from "@bitwarden/angular/jslib.module";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { CardView } from "@bitwarden/common/vault/models/view/card.view";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { normalizeExpiryYearFormat } from "@bitwarden/common/vault/utils";
import {
CardComponent,
FormFieldModule,
@@ -101,9 +102,7 @@ export class CardDetailsSectionComponent implements OnInit {
.pipe(takeUntilDestroyed())
.subscribe(({ cardholderName, number, brand, expMonth, expYear, code }) => {
this.cipherFormContainer.patchCipher((cipher) => {
// The input[type="number"] is returning a number, convert it to a string
// An empty field returns null, avoid casting `"null"` to a string
const expirationYear = expYear !== null ? `${expYear}` : null;
const expirationYear = normalizeExpiryYearFormat(expYear);
Object.assign(cipher.card, {
cardholderName,