From f712b809e27efc761dfafc3e4ff8d45101de9d80 Mon Sep 17 00:00:00 2001 From: Ed Geraghty Date: Tue, 21 May 2024 14:49:12 +0100 Subject: [PATCH] Remove code smell assertion identified by Sonar (#12547) * This assertion is unnecessary since the receiver accepts the original type of the expression * Implement `client.getDomain()` null check * Update comment since `AutoDiscovery.findClientConfig` may still throw --- src/SlidingSyncManager.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/SlidingSyncManager.ts b/src/SlidingSyncManager.ts index c4387e85d6..4885ffa8dc 100644 --- a/src/SlidingSyncManager.ts +++ b/src/SlidingSyncManager.ts @@ -359,10 +359,14 @@ export class SlidingSyncManager { let proxyUrl: string | undefined; try { - const clientWellKnown = await AutoDiscovery.findClientConfig(client.getDomain()!); + const clientDomain = await client.getDomain(); + if (clientDomain === null) { + throw new RangeError("Homeserver domain is null"); + } + const clientWellKnown = await AutoDiscovery.findClientConfig(clientDomain); proxyUrl = clientWellKnown?.["org.matrix.msc3575.proxy"]?.url; } catch (e) { - // client.getDomain() is invalid, `AutoDiscovery.findClientConfig` has thrown + // Either client.getDomain() is null so we've shorted out, or is invalid so `AutoDiscovery.findClientConfig` has thrown } if (proxyUrl != undefined) {