password agent import updates for alt format

This commit is contained in:
Kyle Spearrin 2019-08-02 09:51:00 -04:00
parent 6372d24104
commit ee91cfc2df
1 changed files with 11 additions and 6 deletions

View File

@ -17,19 +17,24 @@ export class PasswordAgentCsvImporter extends BaseImporter implements Importer {
if (value.length !== 5 && value.length < 9) {
return;
}
const altFormat = value.length === 10 && value[0] === '0';
const cipher = this.initLoginCipher();
cipher.name = this.getValueOrDefault(value[0], '--');
cipher.login.username = this.getValueOrDefault(value[1]);
cipher.login.password = this.getValueOrDefault(value[2]);
cipher.name = this.getValueOrDefault(value[altFormat ? 1 : 0], '--');
cipher.login.username = this.getValueOrDefault(value[altFormat ? 2 : 1]);
cipher.login.password = this.getValueOrDefault(value[altFormat ? 3 : 2]);
if (value.length === 5) {
newVersion = false;
cipher.notes = this.getValueOrDefault(value[4]);
cipher.login.uris = this.makeUriArray(value[3]);
} else {
const folder = this.getValueOrDefault(value[8], '(None)');
const folderName = folder !== '(None)' ? folder.split('\\').join('/') : null;
const folder = this.getValueOrDefault(value[altFormat ? 9 : 8], '(None)');
let folderName = folder !== '(None)' ? folder.split('\\').join('/') : null;
if (folderName != null) {
folderName = folder.split(' > ').join('/');
folderName = folder.split('>').join('/');
}
this.processFolder(result, folderName);
cipher.notes = this.getValueOrDefault(value[3]);
cipher.notes = this.getValueOrDefault(value[altFormat ? 5 : 3]);
cipher.login.uris = this.makeUriArray(value[4]);
}
this.convertToNoteIfNeeded(cipher);