Skip to content

Commit

Permalink
Fix UsafeAlert
Browse files Browse the repository at this point in the history
  • Loading branch information
KoalaSat committed Sep 26, 2022
1 parent d356fa2 commit 597a2ca
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions frontend/src/components/UnsafeAlert.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,21 @@ 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];
}

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 = [
Expand All @@ -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) {
Expand Down Expand Up @@ -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 (
<div>
<MediaQuery minWidth={800}>
Expand Down

0 comments on commit 597a2ca

Please sign in to comment.