bitwarden-estensione-browser/libs/common/src/models/export/loginUriExport.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

42 lines
1.0 KiB
TypeScript
Raw Normal View History

2018-12-17 16:29:37 +01:00
import { UriMatchType } from "../../enums/uriMatchType";
import { EncString } from "../domain/encString";
import { LoginUri as LoginUriDomain } from "../domain/loginUri";
2022-02-22 15:39:11 +01:00
import { LoginUriView } from "../view/loginUriView";
2022-04-19 13:03:04 +02:00
export class LoginUriExport {
static template(): LoginUriExport {
const req = new LoginUriExport();
2018-12-17 16:29:37 +01:00
req.uri = "https://google.com";
req.match = null;
return req;
2021-12-16 13:36:21 +01:00
}
2022-04-19 13:03:04 +02:00
static toView(req: LoginUriExport, view = new LoginUriView()) {
2018-12-17 16:29:37 +01:00
view.uri = req.uri;
view.match = req.match;
return view;
2021-12-16 13:36:21 +01:00
}
2022-04-19 13:03:04 +02:00
static toDomain(req: LoginUriExport, domain = new LoginUriDomain()) {
domain.uri = req.uri != null ? new EncString(req.uri) : null;
domain.match = req.match;
return domain;
2021-12-16 13:36:21 +01:00
}
2018-12-17 16:29:37 +01:00
uri: string;
match: UriMatchType = null;
2021-12-16 13:36:21 +01:00
constructor(o?: LoginUriView | LoginUriDomain) {
2018-12-17 16:29:37 +01:00
if (o == null) {
2021-12-16 13:36:21 +01:00
return;
2018-12-17 16:29:37 +01:00
}
if (o instanceof LoginUriView) {
this.uri = o.uri;
} else {
this.uri = o.uri?.encryptedString;
2018-12-17 16:29:37 +01:00
}
this.match = o.match;
2021-12-16 13:36:21 +01:00
}
2018-12-17 16:29:37 +01:00
}