From 58ba1ce5b6183d73c1aeb51a1fe6a7f636fdc774 Mon Sep 17 00:00:00 2001 From: Matt Smith Date: Mon, 13 Jul 2020 13:35:37 -0500 Subject: [PATCH 1/4] Modified response to include port if exists --- src/misc/utils.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/misc/utils.ts b/src/misc/utils.ts index e9b8b4911d..119e9361ed 100644 --- a/src/misc/utils.ts +++ b/src/misc/utils.ts @@ -157,7 +157,13 @@ export class Utils { static getHostname(uriString: string): string { const url = Utils.getUrl(uriString); try { - return url != null && url.hostname !== '' ? url.hostname : null; + let hostname = url != null && url.hostname !== '' ? url.hostname : null; + + if(hostname != null && url.port !== '') { + hostname += ":" + url.port; + } + + return hostname; } catch { return null; } From 49b796ebd695dd69dee89809445dad0e454d2b1e Mon Sep 17 00:00:00 2001 From: Matt Smith Date: Mon, 13 Jul 2020 13:39:38 -0500 Subject: [PATCH 2/4] Formatting change --- src/misc/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/misc/utils.ts b/src/misc/utils.ts index 119e9361ed..806aeb5a74 100644 --- a/src/misc/utils.ts +++ b/src/misc/utils.ts @@ -159,7 +159,7 @@ export class Utils { try { let hostname = url != null && url.hostname !== '' ? url.hostname : null; - if(hostname != null && url.port !== '') { + if (hostname != null && url.port !== '') { hostname += ":" + url.port; } From 82230112487cc487f7298af8b567b4f7beb24988 Mon Sep 17 00:00:00 2001 From: Matt Smith Date: Mon, 13 Jul 2020 15:47:55 -0500 Subject: [PATCH 3/4] Reverted prior change. Changed call to getHost --- src/misc/utils.ts | 8 +------- src/models/view/loginUriView.ts | 2 +- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/misc/utils.ts b/src/misc/utils.ts index 806aeb5a74..e9b8b4911d 100644 --- a/src/misc/utils.ts +++ b/src/misc/utils.ts @@ -157,13 +157,7 @@ export class Utils { static getHostname(uriString: string): string { const url = Utils.getUrl(uriString); try { - let hostname = url != null && url.hostname !== '' ? url.hostname : null; - - if (hostname != null && url.port !== '') { - hostname += ":" + url.port; - } - - return hostname; + return url != null && url.hostname !== '' ? url.hostname : null; } catch { return null; } diff --git a/src/models/view/loginUriView.ts b/src/models/view/loginUriView.ts index afa6e200fd..ce3dfca0eb 100644 --- a/src/models/view/loginUriView.ts +++ b/src/models/view/loginUriView.ts @@ -62,7 +62,7 @@ export class LoginUriView implements View { return null; } if (this._hostname == null && this.uri != null) { - this._hostname = Utils.getHostname(this.uri); + this._hostname = Utils.getHost(this.uri); if (this._hostname === '') { this._hostname = null; } From b53046d0d9cf8a5bd4ed860b91133cafec824b73 Mon Sep 17 00:00:00 2001 From: Matt Smith Date: Tue, 14 Jul 2020 10:02:07 -0500 Subject: [PATCH 4/4] Added new _host property for consumption. --- src/models/view/loginUriView.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/models/view/loginUriView.ts b/src/models/view/loginUriView.ts index ce3dfca0eb..7ef9fa092e 100644 --- a/src/models/view/loginUriView.ts +++ b/src/models/view/loginUriView.ts @@ -26,6 +26,7 @@ export class LoginUriView implements View { private _uri: string = null; private _domain: string = null; private _hostname: string = null; + private _host: string = null; private _canLaunch: boolean = null; // tslint:enable @@ -62,7 +63,7 @@ export class LoginUriView implements View { return null; } if (this._hostname == null && this.uri != null) { - this._hostname = Utils.getHost(this.uri); + this._hostname = Utils.getHostname(this.uri); if (this._hostname === '') { this._hostname = null; } @@ -71,10 +72,28 @@ export class LoginUriView implements View { return this._hostname; } + get host(): string { + if (this.match === UriMatchType.RegularExpression) { + return null; + } + if (this._host == null && this.uri != null) { + this._host = Utils.getHost(this.uri); + if (this._host === '') { + this._host = null; + } + } + + return this._host; + } + get hostnameOrUri(): string { return this.hostname != null ? this.hostname : this.uri; } + get hostOrUri(): string { + return this.host != null ? this.host : this.uri; + } + get isWebsite(): boolean { return this.uri != null && (this.uri.indexOf('http://') === 0 || this.uri.indexOf('https://') === 0 || (this.uri.indexOf('://') < 0 && Utils.tldEndingRegex.test(this.uri)));