From d69862c46d285a5efa8581befd216d9b7365fc5c Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 29 Jan 2019 09:32:20 -0500 Subject: [PATCH] autofill exp year when it is a select list --- jslib | 2 +- src/services/autofill.service.ts | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/jslib b/jslib index b01709240e..9e97b1e656 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit b01709240e4fc0674caea4edfebe5e46249c2bd2 +Subproject commit 9e97b1e65641452ec8ae2d2e1fca4bfddcd769b7 diff --git a/src/services/autofill.service.ts b/src/services/autofill.service.ts index f14f4b8809..b2bd2c4cdd 100644 --- a/src/services/autofill.service.ts +++ b/src/services/autofill.service.ts @@ -509,7 +509,23 @@ export default class AutofillService implements AutofillServiceInterface { if (fillFields.expYear && this.hasValue(card.expYear)) { let expYear: string = card.expYear; - if (this.fieldAttrsContain(fillFields.expYear, 'yyyy') || fillFields.expYear.maxLength === 4) { + if (fillFields.expYear.selectInfo && fillFields.expYear.selectInfo.options) { + for (let i = 0; i < fillFields.expYear.selectInfo.options.length; i++) { + const o: [string, string] = fillFields.expYear.selectInfo.options[i]; + if (o[0] === card.expYear) { + expYear = o[1]; + break; + } + const colonIndex = o[1].indexOf(':'); + if (colonIndex > -1 && o[1].length > colonIndex + 1) { + const val = o[1].substring(colonIndex + 2); + if (val != null && val.trim() !== '' && val === card.expYear) { + expYear = o[1]; + break; + } + } + } + } else if (this.fieldAttrsContain(fillFields.expYear, 'yyyy') || fillFields.expYear.maxLength === 4) { if (expYear.length === 2) { expYear = '20' + expYear; }