From 5d8f43ab9a9509684677e35ecd62475d920aaf4e Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 14 Jan 2019 22:45:12 -0500 Subject: [PATCH] check maxLength --- src/models/autofillField.ts | 1 + src/services/autofill.service.ts | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/models/autofillField.ts b/src/models/autofillField.ts index 6cfe2de89e..0223e50c07 100644 --- a/src/models/autofillField.ts +++ b/src/models/autofillField.ts @@ -20,4 +20,5 @@ export default class AutofillField { form: string; autoCompleteType: string; selectInfo: any; + maxLength: number; } diff --git a/src/services/autofill.service.ts b/src/services/autofill.service.ts index e42ab687f0..cf97bc54e3 100644 --- a/src/services/autofill.service.ts +++ b/src/services/autofill.service.ts @@ -497,7 +497,8 @@ export default class AutofillService implements AutofillServiceInterface { expMonth = option[1]; } } - } else if (this.fieldAttrsContain(fillFields.expMonth, 'mm') && expMonth.length === 1) { + } else if ((this.fieldAttrsContain(fillFields.expMonth, 'mm') || fillFields.expMonth.maxLength === 2) + && expMonth.length === 1) { expMonth = '0' + expMonth; } @@ -508,11 +509,11 @@ export default class AutofillService implements AutofillServiceInterface { if (fillFields.expYear && this.hasValue(card.expYear)) { let expYear: string = card.expYear; - if (this.fieldAttrsContain(fillFields.expYear, 'yyyy')) { + if (this.fieldAttrsContain(fillFields.expYear, 'yyyy') || fillFields.expYear.maxLength === 4) { if (expYear.length === 2) { expYear = '20' + expYear; } - } else if (this.fieldAttrsContain(fillFields.expYear, 'yy')) { + } else if (this.fieldAttrsContain(fillFields.expYear, 'yy') || fillFields.expYear.maxLength === 2) { if (expYear.length === 4) { expYear = expYear.substr(2); }