1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-14 07:13:32 +00:00

[EC-417] Extracting the app name from the Android user item on CSV import (#3254)

* [EC-417] Extracting the app name from the Android user item on CSV import

* [EC-417] Updated android csv pattern to match starting with 'android://'

* [EC-417] Added unit tests for ChromeCsvImporter
This commit is contained in:
Rui Tomé
2022-10-25 09:49:57 +01:00
committed by GitHub
parent 321aee1625
commit 754ea1e09a
4 changed files with 83 additions and 1 deletions

View File

@@ -4,6 +4,8 @@ import { BaseImporter } from "./baseImporter";
import { Importer } from "./importer";
export class ChromeCsvImporter extends BaseImporter implements Importer {
private androidPatternRegex = new RegExp("^android:\\/\\/.*(?<=@)(.*)(?=\\/)");
parse(data: string): Promise<ImportResult> {
const result = new ImportResult();
const results = this.parseCsv(data, true);
@@ -14,7 +16,11 @@ export class ChromeCsvImporter extends BaseImporter implements Importer {
results.forEach((value) => {
const cipher = this.initLoginCipher();
cipher.name = this.getValueOrDefault(value.name, "--");
let name = value.name;
if (!name && this.androidPatternRegex.test(value.url)) {
name = value.url.match(this.androidPatternRegex)[1];
}
cipher.name = this.getValueOrDefault(name, "--");
cipher.login.username = this.getValueOrDefault(value.username);
cipher.login.password = this.getValueOrDefault(value.password);
cipher.login.uris = this.makeUriArray(value.url);