diff --git a/src/js/login.js b/src/js/login.js index 725ef4e..83353cd 100644 --- a/src/js/login.js +++ b/src/js/login.js @@ -129,15 +129,15 @@ class Form extends ElemJS { this.status(`Looking up homeserver... trying ${address}`) // Check if we found the actual matrix server - try { - const versionsReq = await fetch(`${address}/_matrix/client/versions`) - if(versionsReq.ok) { - const versions = await versionsReq.json() - if (Array.isArray(versions.versions)) { - return address - } - } - } catch(e) {} + const versionsReq = await fetch(`${address}/_matrix/client/versions`).catch(()=>{}) + /* jshint ignore:start */ + //JsHint doesn't support optional chaining + // https://github.com/jshint/jshint/issues/3448 + if(versionsReq?.ok) { + const versions = await versionsReq.json().catch(()=>{}) + if (Array.isArray(versions?.versions)) return address + } + /* jshint ignore:end */ // find the next matrix server in the chain const root = await fetch(`${address}/.well-known/matrix/client`).then(res => res.json()).catch(e => {