Remove trailing slash in checkServer
This commit is contained in:
parent
3fae58439b
commit
6696a8b3ca
|
@ -247,7 +247,19 @@ class Client {
|
||||||
/// Throws FormatException, TimeoutException and MatrixException on error.
|
/// Throws FormatException, TimeoutException and MatrixException on error.
|
||||||
Future<bool> checkServer(dynamic serverUrl) async {
|
Future<bool> checkServer(dynamic serverUrl) async {
|
||||||
try {
|
try {
|
||||||
api.homeserver = (serverUrl is Uri) ? serverUrl : Uri.parse(serverUrl);
|
if (serverUrl is Uri) {
|
||||||
|
api.homeserver = serverUrl;
|
||||||
|
} else {
|
||||||
|
// URLs allow to have whitespace surrounding them, see https://www.w3.org/TR/2011/WD-html5-20110525/urls.html
|
||||||
|
// As we want to strip a trailing slash, though, we have to trim the url ourself
|
||||||
|
// and thus can't let Uri.parse() deal with it.
|
||||||
|
serverUrl = serverUrl.trim();
|
||||||
|
// strip a trailing slash
|
||||||
|
if (serverUrl.endsWith('/')) {
|
||||||
|
serverUrl = serverUrl.substring(0, serverUrl.length - 1);
|
||||||
|
}
|
||||||
|
api.homeserver = Uri.parse(serverUrl);
|
||||||
|
}
|
||||||
final versions = await api.requestSupportedVersions();
|
final versions = await api.requestSupportedVersions();
|
||||||
|
|
||||||
for (var i = 0; i < versions.versions.length; i++) {
|
for (var i = 0; i < versions.versions.length; i++) {
|
||||||
|
|
Loading…
Reference in a new issue