aboutsummaryrefslogtreecommitdiff
path: root/lib/uri.cpp
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2021-06-13 18:15:36 +0200
committerGitHub <noreply@github.com>2021-06-13 18:15:36 +0200
commitd20aa002c0dcb2b40bbf7b48c5c995a5ed8138c1 (patch)
tree713338c8bde5e6784bbdfcdee29cafc1f9eb36d4 /lib/uri.cpp
parent0571ba1fb1948a6cc050230a85201291ababbf04 (diff)
parent083f62f58bc525d761969133e12a859de9b29648 (diff)
downloadlibquotient-d20aa002c0dcb2b40bbf7b48c5c995a5ed8138c1.tar.gz
libquotient-d20aa002c0dcb2b40bbf7b48c5c995a5ed8138c1.zip
Merge pull request #480 from quotient-im/kitsune-qt6-compat
Qt 6 support
Diffstat (limited to 'lib/uri.cpp')
-rw-r--r--lib/uri.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/uri.cpp b/lib/uri.cpp
index 291bfcae..c8843dda 100644
--- a/lib/uri.cpp
+++ b/lib/uri.cpp
@@ -70,7 +70,7 @@ static QString pathSegment(const QUrl& url, int which)
encodedPath(url).section('/', which, which).toUtf8());
}
-static auto decodeFragmentPart(const QStringRef& part)
+static auto decodeFragmentPart(QStringView part)
{
return QUrl::fromPercentEncoding(part.toLatin1()).toUtf8();
}
@@ -98,7 +98,7 @@ Uri::Uri(QUrl url) : QUrl(std::move(url))
if (scheme() == "matrix") {
// Check sanity as per https://github.com/matrix-org/matrix-doc/pull/2312
const auto& urlPath = encodedPath(*this);
- const auto& splitPath = urlPath.splitRef('/');
+ const auto& splitPath = urlPath.split('/');
switch (splitPath.size()) {
case 2:
break;
@@ -128,9 +128,9 @@ Uri::Uri(QUrl url) : QUrl(std::move(url))
// so force QUrl to decode everything.
auto f = fragment(QUrl::EncodeUnicode);
if (auto&& m = MatrixToUrlRE.match(f); m.hasMatch())
- *this = Uri { decodeFragmentPart(m.capturedRef("main")),
- decodeFragmentPart(m.capturedRef("sec")),
- decodeFragmentPart(m.capturedRef("query")) };
+ *this = Uri { decodeFragmentPart(m.capturedView(u"main")),
+ decodeFragmentPart(m.capturedView(u"sec")),
+ decodeFragmentPart(m.capturedView(u"query")) };
}
}
@@ -186,14 +186,18 @@ QString Uri::primaryId() const
if (primaryType_ == Empty || primaryType_ == Invalid)
return {};
- const auto& idStem = pathSegment(*this, 1);
- return idStem.isEmpty() ? idStem : primaryType_ + idStem;
+ auto idStem = pathSegment(*this, 1);
+ if (!idStem.isEmpty())
+ idStem.push_front(char(primaryType_));
+ return idStem;
}
QString Uri::secondaryId() const
{
- const auto& idStem = pathSegment(*this, 3);
- return idStem.isEmpty() ? idStem : secondaryType() + idStem;
+ auto idStem = pathSegment(*this, 3);
+ if (!idStem.isEmpty())
+ idStem.push_front(char(secondaryType()));
+ return idStem;
}
static const auto ActionKey = QStringLiteral("action");