Clean up code
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing

This commit is contained in:
Bad 2020-10-23 10:51:04 +02:00
parent 4382928a93
commit aa12cd68e6

View file

@ -128,15 +128,13 @@ class Form extends ElemJS {
this.status(`Looking up homeserver... trying ${address}`)
// Check if we found the actual matrix server
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
try {
const versionsReq = await fetch(`${address}/_matrix/client/versions`)
if (versionsReq.ok) {
const versions = await versionsReq.json()
if (Array.isArray(versions.versions)) return address
}
/* jshint ignore:end */
} catch(e) {}
// Find the next matrix server in the chain
const root = await fetch(`${address}/.well-known/matrix/client`).then(res => res.json()).catch(e => {