mirror of
https://github.com/bitwarden/browser
synced 2025-12-13 14:53:33 +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:
committed by
GitHub
parent
a6755f5f20
commit
dba910d0b9
@@ -2,6 +2,8 @@ import { EncString } from "../../platform/models/domain/enc-string";
|
||||
import { Folder as FolderDomain } from "../../vault/models/domain/folder";
|
||||
import { FolderView } from "../../vault/models/view/folder.view";
|
||||
|
||||
import { safeGetString } from "./utils";
|
||||
|
||||
export class FolderExport {
|
||||
static template(): FolderExport {
|
||||
const req = new FolderExport();
|
||||
@@ -23,10 +25,6 @@ export class FolderExport {
|
||||
|
||||
// Use build method instead of ctor so that we can control order of JSON stringify for pretty print
|
||||
build(o: FolderView | FolderDomain) {
|
||||
if (o instanceof FolderView) {
|
||||
this.name = o.name;
|
||||
} else {
|
||||
this.name = o.name?.encryptedString;
|
||||
}
|
||||
this.name = safeGetString(o.name);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user