From 3ea0e79a36b72878a938a8c41b4c1271668fd429 Mon Sep 17 00:00:00 2001 From: Jedi18 Date: Fri, 19 Feb 2021 17:04:31 +0530 Subject: [PATCH] check for empty alias and percent encoding for alias in url --- src/RoomsModel.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/RoomsModel.cpp b/src/RoomsModel.cpp index 213d84df..4286f87b 100644 --- a/src/RoomsModel.cpp +++ b/src/RoomsModel.cpp @@ -1,5 +1,7 @@ #include "RoomsModel.h" +#include + #include "Cache_p.h" #include "CompletionModelRoles.h" @@ -14,7 +16,7 @@ RoomsModel::RoomsModel(bool showOnlyRoomWithAliases, QObject *parent) auto roomAliasesList = cache::client()->getRoomAliases(r); if (showOnlyRoomWithAliases_) { - if (roomAliasesList) { + if (roomAliasesList && !roomAliasesList->alias.empty()) { roomids.push_back(QString::fromStdString(r)); roomAliases.push_back( QString::fromStdString(roomAliasesList->alias)); @@ -44,8 +46,11 @@ RoomsModel::data(const QModelIndex &index, int role) const { if (hasIndex(index.row(), index.column(), index.parent())) { switch (role) { - case CompletionModel::CompletionRole: - return QString("[%1](https://matrix.to/%1)").arg(roomAliases[index.row()]); + case CompletionModel::CompletionRole: { + QString percentEncoding = QUrl::toPercentEncoding(roomAliases[index.row()]); + return QString("[%1](https://matrix.to/#/%2)") + .arg(roomAliases[index.row()], percentEncoding); + } case CompletionModel::SearchRole: case Qt::DisplayRole: case Roles::RoomAlias: