Skip to content
This repository has been archived by the owner on Jun 17, 2022. It is now read-only.

Commit

Permalink
name from url
Browse files Browse the repository at this point in the history
  • Loading branch information
kspearrin committed Jun 25, 2018
1 parent 1aa774b commit 0d2cd4c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/importers/aviraCsvImporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 10 additions & 0 deletions src/importers/baseImporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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() === '';
}
Expand Down

0 comments on commit 0d2cd4c

Please sign in to comment.