From 50d242e53a4b553a6cb3575945a84812eda75b1d Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 18 Jan 2019 23:42:03 -0500 Subject: [PATCH] fix kvp splits on secure note mapping --- src/importers/lastpassCsvImporter.ts | 31 +++++++++++++++++++--------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/importers/lastpassCsvImporter.ts b/src/importers/lastpassCsvImporter.ts index a20008c569..cbfebfec41 100644 --- a/src/importers/lastpassCsvImporter.ts +++ b/src/importers/lastpassCsvImporter.ts @@ -210,28 +210,39 @@ export class LastPassCsvImporter extends BaseImporter implements Importer { const dataObj: any = {}; extraParts.forEach((extraPart) => { - const fieldParts = extraPart.split(':'); - if (fieldParts.length < 1 || this.isNullOrWhitespace(fieldParts[0]) || - this.isNullOrWhitespace(fieldParts[1]) || fieldParts[0] === 'NoteType') { + if (this.isNullOrWhitespace(extraPart)) { + return; + } + let key: string = null; + let val: string = null; + const colonIndex = extraPart.indexOf(':'); + if (colonIndex === -1) { + key = extraPart; + } else { + key = extraPart.substring(0, colonIndex); + if (extraPart.length > colonIndex) { + val = extraPart.substring(colonIndex + 1); + } + } + if (this.isNullOrWhitespace(key) || this.isNullOrWhitespace(val) || key === 'NoteType') { return; } - if (fieldParts[0] === 'Notes') { + if (key === 'Notes') { if (!this.isNullOrWhitespace(notes)) { - notes += ('\n' + fieldParts[1]); + notes += ('\n' + val); } else { - notes = fieldParts[1]; + notes = val; } - } else if (map.hasOwnProperty(fieldParts[0])) { - dataObj[map[fieldParts[0]]] = fieldParts[1]; + } else if (map.hasOwnProperty(key)) { + dataObj[map[key]] = val; } else { if (!this.isNullOrWhitespace(notes)) { notes += '\n'; } else { notes = ''; } - - notes += (fieldParts[0] + ': ' + fieldParts[1]); + notes += (key + ': ' + val); } });