From c175674cd8868f4231a4692a62c3a9421fb32c0a Mon Sep 17 00:00:00 2001 From: Inex Code Date: Wed, 14 Oct 2020 23:07:36 +0300 Subject: [PATCH] Fix login fail on browser --- lib/src/client.dart | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/src/client.dart b/lib/src/client.dart index cdb554c..3a24d31 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -225,11 +225,14 @@ class Client extends MatrixApi { var wellKnown = WellKnownInformations.fromJson(json.decode(response.body)); if (Uri.parse(wellKnown.mHomeserver.baseUrl).host != MatrixIdOrDomain.domain) { - final response = await http.get( - 'https://${Uri.parse(wellKnown.mHomeserver.baseUrl).host}/.well-known/matrix/client'); - if (response.statusCode == 200) { - wellKnown = WellKnownInformations.fromJson(json.decode(response.body)); - } + try { + final response = await http.get( + 'https://${Uri.parse(wellKnown.mHomeserver.baseUrl).host}/.well-known/matrix/client'); + if (response.statusCode == 200) { + wellKnown = + WellKnownInformations.fromJson(json.decode(response.body)); + } + } catch (_) {} } return wellKnown; } @@ -241,11 +244,14 @@ class Client extends MatrixApi { await http.get('https://${homeserver.host}/.well-known/matrix/client'); var wellKnown = WellKnownInformations.fromJson(json.decode(response.body)); if (Uri.parse(wellKnown.mHomeserver.baseUrl).host != homeserver.host) { - final response = await http.get( - 'https://${Uri.parse(wellKnown.mHomeserver.baseUrl).host}/.well-known/matrix/client'); - if (response.statusCode == 200) { - wellKnown = WellKnownInformations.fromJson(json.decode(response.body)); - } + try { + final response = await http.get( + 'https://${Uri.parse(wellKnown.mHomeserver.baseUrl).host}/.well-known/matrix/client'); + if (response.statusCode == 200) { + wellKnown = + WellKnownInformations.fromJson(json.decode(response.body)); + } + } catch (_) {} } return wellKnown; }