diff options
-rw-r--r-- | lib/connection.cpp | 2 | ||||
-rw-r--r-- | lib/jobs/basejob.cpp | 7 | ||||
-rw-r--r-- | lib/jobs/basejob.h | 6 |
3 files changed, 9 insertions, 6 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp index 1c63adeb..41ecee67 100644 --- a/lib/connection.cpp +++ b/lib/connection.cpp @@ -280,7 +280,7 @@ void Connection::resolveServer(const QString& mxid) return; } qCInfo(MAIN) << ".well-known URL for" << maybeBaseUrl.host() - << "is" << baseUrl.authority(); + << "is" << baseUrl.toString(); setHomeserver(baseUrl); } else { qCInfo(MAIN) << "No .well-known file, using" << maybeBaseUrl diff --git a/lib/jobs/basejob.cpp b/lib/jobs/basejob.cpp index 7cddc343..8e1a63aa 100644 --- a/lib/jobs/basejob.cpp +++ b/lib/jobs/basejob.cpp @@ -212,8 +212,11 @@ QUrl BaseJob::makeRequestUrl(QUrl baseUrl, const QString& path, const QUrlQuery& query) { auto pathBase = baseUrl.path(); - if (!pathBase.endsWith('/') && !path.startsWith('/')) - pathBase.push_back('/'); + // QUrl::adjusted(QUrl::StripTrailingSlashes) doesn't help with root '/' + while (pathBase.endsWith('/')) + pathBase.chop(1); + if (!path.startsWith('/')) // Normally API files do start with '/' + pathBase.push_back('/'); // so this shouldn't be needed these days baseUrl.setPath(pathBase + path, QUrl::TolerantMode); baseUrl.setQuery(query); diff --git a/lib/jobs/basejob.h b/lib/jobs/basejob.h index c8046e9e..2049f59c 100644 --- a/lib/jobs/basejob.h +++ b/lib/jobs/basejob.h @@ -308,9 +308,9 @@ protected: void setExpectedContentTypes(const QByteArrayList& contentTypes); /** Construct a URL out of baseUrl, path and query - * The function automatically adds '/' between baseUrl's path and - * \p path if necessary. The query component of \p baseUrl - * is ignored. + * + * The function ensures exactly one '/' between the path component of + * \p baseUrl and \p path. The query component of \p baseUrl is ignored. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& path, const QUrlQuery& query = {}); |