diff --git a/src/importers/aviraCsvImporter.ts b/src/importers/aviraCsvImporter.ts index d704028624..bb10ad3927 100644 --- a/src/importers/aviraCsvImporter.ts +++ b/src/importers/aviraCsvImporter.ts @@ -20,7 +20,8 @@ export class AviraCsvImporter extends BaseImporter implements Importer { results.forEach((value) => { const cipher = new CipherView(); cipher.type = CipherType.Login; - cipher.name = this.getValueOrDefault(value.name, '--'); + cipher.name = this.getValueOrDefault(value.name, + this.getValueOrDefault(this.nameFromUrl(value.website), '--')); cipher.login = new LoginView(); cipher.login.uris = this.makeUriArray(value.website); cipher.login.password = this.getValueOrDefault(value.password); diff --git a/src/importers/baseImporter.ts b/src/importers/baseImporter.ts index dccd7114e7..c1a245e510 100644 --- a/src/importers/baseImporter.ts +++ b/src/importers/baseImporter.ts @@ -2,6 +2,8 @@ import * as papa from 'papaparse'; import { LoginUriView } from '../models/view/loginUriView'; +import { Utils } from '../misc/utils'; + export abstract class BaseImporter { protected passwordFieldNames = [ 'password', 'pass word', 'passphrase', 'pass phrase', @@ -112,6 +114,14 @@ export abstract class BaseImporter { return uri; } + protected nameFromUrl(url: string) { + const hostname = Utils.getHostname(url); + if (this.isNullOrWhitespace(hostname)) { + return null; + } + return hostname.startsWith('www.') ? hostname.replace('www.', '') : hostname; + } + protected isNullOrWhitespace(str: string): boolean { return str == null || str.trim() === ''; }