name from url

This commit is contained in:
Kyle Spearrin 2018-06-25 15:19:51 -04:00
parent 1aa774b99f
commit 0d2cd4c482
2 changed files with 12 additions and 1 deletions

View File

@ -20,7 +20,8 @@ export class AviraCsvImporter extends BaseImporter implements Importer {
results.forEach((value) => { results.forEach((value) => {
const cipher = new CipherView(); const cipher = new CipherView();
cipher.type = CipherType.Login; 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 = new LoginView();
cipher.login.uris = this.makeUriArray(value.website); cipher.login.uris = this.makeUriArray(value.website);
cipher.login.password = this.getValueOrDefault(value.password); cipher.login.password = this.getValueOrDefault(value.password);

View File

@ -2,6 +2,8 @@ import * as papa from 'papaparse';
import { LoginUriView } from '../models/view/loginUriView'; import { LoginUriView } from '../models/view/loginUriView';
import { Utils } from '../misc/utils';
export abstract class BaseImporter { export abstract class BaseImporter {
protected passwordFieldNames = [ protected passwordFieldNames = [
'password', 'pass word', 'passphrase', 'pass phrase', 'password', 'pass word', 'passphrase', 'pass phrase',
@ -112,6 +114,14 @@ export abstract class BaseImporter {
return uri; 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 { protected isNullOrWhitespace(str: string): boolean {
return str == null || str.trim() === ''; return str == null || str.trim() === '';
} }