1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-19 17:53:39 +00:00

Create and use safeGetString() instead of instanceof checks to determine type (#8906)

`safeGetString` takes a `string` or `EncString` and return the appropiate value based on it's type

Co-authored-by: Daniel James Smith <djsmith85@users.noreply.github.com>
This commit is contained in:
Daniel James Smith
2024-04-24 23:41:35 +02:00
committed by GitHub
parent a6755f5f20
commit dba910d0b9
11 changed files with 82 additions and 137 deletions

View File

@@ -3,6 +3,8 @@ import { FieldType, LinkedIdType } from "../../vault/enums";
import { Field as FieldDomain } from "../../vault/models/domain/field";
import { FieldView } from "../../vault/models/view/field.view";
import { safeGetString } from "./utils";
export class FieldExport {
static template(): FieldExport {
const req = new FieldExport();
@@ -38,13 +40,8 @@ export class FieldExport {
return;
}
if (o instanceof FieldView) {
this.name = o.name;
this.value = o.value;
} else {
this.name = o.name?.encryptedString;
this.value = o.value?.encryptedString;
}
this.name = safeGetString(o.name);
this.value = safeGetString(o.value);
this.type = o.type;
this.linkedId = o.linkedId;
}