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
This commit is contained in:
Ed Geraghty 2024-05-21 14:49:12 +01:00 committed by GitHub
parent 3342aa5ff8
commit f712b809e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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) {