1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-05 09:10:53 +01:00

cache canLaunch result

This commit is contained in:
Kyle Spearrin 2018-11-02 13:03:00 -04:00
parent ff981532fd
commit 4a13e62477

View File

@ -23,6 +23,7 @@ export class LoginUriView implements View {
private _uri: string;
private _domain: string;
private _hostname: string;
private _canLaunch: boolean;
// tslint:enable
constructor(u?: LoginUri) {
@ -39,6 +40,7 @@ export class LoginUriView implements View {
set uri(value: string) {
this._uri = value;
this._domain = null;
this._canLaunch = null;
}
get domain(): string {
@ -72,14 +74,18 @@ export class LoginUriView implements View {
}
get canLaunch(): boolean {
if (this.uri == null) {
return false;
if (this._canLaunch != null) {
return this._canLaunch;
}
if (this.uri != null) {
for (let i = 0; i < CanLaunchWhitelist.length; i++) {
if (this.uri.indexOf(CanLaunchWhitelist[i]) === 0) {
return true;
this._canLaunch = true;
return this._canLaunch;
}
}
return false;
}
this._canLaunch = false;
return this._canLaunch;
}
}