Clean up code
This commit is contained in:
		
							parent
							
								
									4382928a93
								
							
						
					
					
						commit
						aa12cd68e6
					
				
					 1 changed files with 7 additions and 9 deletions
				
			
		| 
						 | 
					@ -128,15 +128,13 @@ class Form extends ElemJS {
 | 
				
			||||||
		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
 | 
				
			||||||
		const versionsReq = await fetch(`${address}/_matrix/client/versions`).catch(()=>{})
 | 
							try {
 | 
				
			||||||
		/* jshint ignore:start */
 | 
								const versionsReq = await fetch(`${address}/_matrix/client/versions`)
 | 
				
			||||||
		//JsHint doesn't support optional chaining
 | 
								if (versionsReq.ok) {
 | 
				
			||||||
		// https://github.com/jshint/jshint/issues/3448
 | 
									const versions = await versionsReq.json()
 | 
				
			||||||
		if (versionsReq?.ok) {
 | 
									if (Array.isArray(versions.versions)) return address
 | 
				
			||||||
			const versions = await versionsReq.json().catch(()=>{})
 | 
								}
 | 
				
			||||||
			if (Array.isArray(versions?.versions)) return address
 | 
							} catch(e) {}
 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		/* jshint ignore:end */
 | 
					 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
		// Find the next matrix server in the chain
 | 
							// Find the next matrix server in the chain
 | 
				
			||||||
		const root = await fetch(`${address}/.well-known/matrix/client`).then(res => res.json()).catch(e => {
 | 
							const root = await fetch(`${address}/.well-known/matrix/client`).then(res => res.json()).catch(e => {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue