Small cosmetic fixes
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

This commit is contained in:
Bad 2020-10-21 21:19:17 +02:00
parent 0c3c06bc0a
commit 61cc4a19f3

View file

@ -119,19 +119,20 @@ class Form extends ElemJS {
maxDepth-- maxDepth--
if(maxDepth<=0) throw new Error(`Failed to look up homeserver, maximum search depth reached`) if(maxDepth<=0) throw new Error(`Failed to look up homeserver, maximum search depth reached`)
//Preprocess the address
if (!address.match(/^https?:\/\//)) { if (!address.match(/^https?:\/\//)) {
console.warn(`${address} doesn't specify the protocol, assuming https`) console.warn(`${address} doesn't specify the protocol, assuming https`)
address = "https://" + address address = "https://" + address
} }
address = address.replace(/\/*$/, "") address = address.replace(/\/*$/, "")
this.status(`Looking up homeserver... trying ${address}`) this.status(`Looking up homeserver... trying ${address}`)
// check if we found the actual matrix server // Check if we found the actual matrix server
try { try {
const versionsReq = await fetch(`${address}/_matrix/client/versions`) const versionsReq = await fetch(`${address}/_matrix/client/versions`)
if(versionsReq.ok) { if(versionsReq.ok) {
const versions = await versionsReq.json().catch(()=>{}) const versions = await versionsReq.json()
if (Array.isArray(versions.versions)) { if (Array.isArray(versions.versions)) {
return address return address
} }