aboutsummaryrefslogtreecommitdiff
path: root/lib/uri.cpp
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-02-13 19:25:24 +0100
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-02-13 19:25:24 +0100
commit044ae4a029b710571420f830a497647f7a54698a (patch)
tree14d50ba0eb1a5cfac995f13cd6059aed74e506b2 /lib/uri.cpp
parentb0aef4af9cbf00755c7b70c71d77f0bf7ce0d200 (diff)
parent10ac7c13cdcd62b62af6e89cb726376cfbc53302 (diff)
downloadlibquotient-044ae4a029b710571420f830a497647f7a54698a.tar.gz
libquotient-044ae4a029b710571420f830a497647f7a54698a.zip
Merge branch 'dev'
The result is FTBFS as yet; next commits will fix that, along with a few other things.
Diffstat (limited to 'lib/uri.cpp')
-rw-r--r--lib/uri.cpp25
1 files changed, 15 insertions, 10 deletions
diff --git a/lib/uri.cpp b/lib/uri.cpp
index c8843dda..6b7d1d20 100644
--- a/lib/uri.cpp
+++ b/lib/uri.cpp
@@ -3,29 +3,34 @@
#include "uri.h"
+#include "util.h"
#include "logging.h"
#include <QtCore/QRegularExpression>
using namespace Quotient;
-struct ReplacePair { QByteArray uriString; char sigil; };
+namespace {
+
+struct ReplacePair { QLatin1String uriString; char sigil; };
/// \brief Defines bi-directional mapping of path prefixes and sigils
///
/// When there are two prefixes for the same sigil, the first matching
/// entry for a given sigil is used.
-static const auto replacePairs = {
- ReplacePair { "u/", '@' },
- { "user/", '@' },
- { "roomid/", '!' },
- { "r/", '#' },
- { "room/", '#' },
+const ReplacePair replacePairs[] = {
+ { "u/"_ls, '@' },
+ { "user/"_ls, '@' },
+ { "roomid/"_ls, '!' },
+ { "r/"_ls, '#' },
+ { "room/"_ls, '#' },
// The notation for bare event ids is not proposed in MSC2312 but there's
// https://github.com/matrix-org/matrix-doc/pull/2644
- { "e/", '$' },
- { "event/", '$' }
+ { "e/"_ls, '$' },
+ { "event/"_ls, '$' }
};
+}
+
Uri::Uri(QByteArray primaryId, QByteArray secondaryId, QString query)
{
if (primaryId.isEmpty())
@@ -75,7 +80,7 @@ static auto decodeFragmentPart(QStringView part)
return QUrl::fromPercentEncoding(part.toLatin1()).toUtf8();
}
-static auto matrixToUrlRegexInit()
+static inline auto matrixToUrlRegexInit()
{
// See https://matrix.org/docs/spec/appendices#matrix-to-navigation
const QRegularExpression MatrixToUrlRE {