From 597a2ca3de71d6509ba4f17d932464c9ee48b5c4 Mon Sep 17 00:00:00 2001 From: KoalaSat Date: Mon, 26 Sep 2022 10:24:14 +0200 Subject: [PATCH] Fix UsafeAlert --- frontend/src/components/UnsafeAlert.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/UnsafeAlert.js b/frontend/src/components/UnsafeAlert.js index 784a6e8f6..981c3ed34 100644 --- a/frontend/src/components/UnsafeAlert.js +++ b/frontend/src/components/UnsafeAlert.js @@ -14,7 +14,7 @@ class UnsafeAlert extends Component { getHost() { const url = - window.location != window.parent.location + window.location !== window.parent.location ? this.getHost(document.referrer) : document.location.href; return url.split('/')[2]; @@ -22,9 +22,13 @@ class UnsafeAlert extends Component { isSelfhosted() { const http = new XMLHttpRequest(); - http.open('HEAD', `${location.protocol}//${this.getHost()}/selfhosted`, false); - http.send(); - return http.status == 200; + try { + http.open('HEAD', `${location.protocol}//${this.getHost()}/selfhosted`, false); + http.send(); + return http.status === 200; + } catch { + return false; + } } safe_urls = [ @@ -36,7 +40,7 @@ class UnsafeAlert extends Component { ]; render() { - const { t, i18n } = this.props; + const { t } = this.props; // If alert is hidden return null if (!this.state.show) { @@ -68,7 +72,7 @@ class UnsafeAlert extends Component { } // Show unsafe alert - if (!this.safe_urls.includes(this.getHost())) { + if (!this.safe_urls.includes(this.getHost()) && !window.NativeRobosats) { return (