1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-23 11:43:46 +00:00

fix lastpass import credit card expiration (#65)

* Fix import of expiration date from LastPass

Signed-off-by: Felipe Santos <felipecassiors@gmail.com>

* handle empty cc exp from lastpass, add test

* check for month/year null/whitespace

* check for empty expiration from lp import

Co-authored-by: Felipe Santos <felipecassiors@gmail.com>
This commit is contained in:
Reese
2020-02-06 08:24:18 -08:00
committed by GitHub
parent 1859357ddb
commit eecd774b13
2 changed files with 158 additions and 0 deletions

View File

@@ -170,7 +170,29 @@ export class LastPassCsvImporter extends BaseImporter implements Importer {
'Number': 'number',
'Name on Card': 'cardholderName',
'Security Code': 'code',
// LP provides date in a format like 'June,2020'
// Store in expMonth, then parse and modify
'Expiration Date': 'expMonth',
});
const exp = mappedData[0].expMonth;
if (exp === ',' || this.isNullOrWhitespace(exp)) {
// No expiration data
delete mappedData[0].expMonth;
} else {
const [monthString, year] = exp.split(',');
// Parse month name into number
if (!this.isNullOrWhitespace(monthString)) {
const month = new Date(Date.parse(monthString + '1, 2012')).getMonth() + 1;
mappedData[0].expMonth = month.toString();
} else {
delete mappedData[0].expMonth;
}
if (!this.isNullOrWhitespace(year)) {
mappedData[0].expYear = year;
}
}
cipher.type = CipherType.Card;
cipher.card = mappedData[0];
cipher.notes = mappedData[1];