From fed4b4fe965a9e2788055b602c7217cb298f5fce Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Tue, 21 Nov 2017 16:54:39 +0900 Subject: Mitigate the mess with slashes between base URL and endpoint string Closes #125 --- jobs/basejob.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/jobs/basejob.cpp b/jobs/basejob.cpp index 20fb68f6..9d5c5ed6 100644 --- a/jobs/basejob.cpp +++ b/jobs/basejob.cpp @@ -137,7 +137,11 @@ void BaseJob::setRequestData(const BaseJob::Data& data) void BaseJob::Private::sendRequest() { QUrl url = connection->baseUrl(); - url.setPath( url.path() + "/" + apiEndpoint ); + QString path = url.path(); + if (!path.endsWith('/') && !apiEndpoint.startsWith('/')) + path.push_back('/'); + + url.setPath( path + apiEndpoint ); url.setQuery(requestQuery); QNetworkRequest req {url}; @@ -207,6 +211,7 @@ void BaseJob::gotReply() BaseJob::Status BaseJob::checkReply(QNetworkReply* reply) const { + qCDebug(d->logCat) << this << "returned from" << reply->url().toDisplayString(); if (reply->error() != QNetworkReply::NoError) qCDebug(d->logCat) << this << "returned" << reply->error(); switch( reply->error() ) -- cgit v1.2.3