fix: display correct tracker port in qt torrent-details (#4846)

This commit is contained in:
Charles Kerr 2023-02-11 21:46:57 -06:00 committed by GitHub
parent 8cee2f952e
commit 2b3578512c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 3 deletions

View File

@ -9,6 +9,8 @@
#include <QPixmap>
#include <QTextDocument>
#include <libtransmission/web-utils.h>
#include "FaviconCache.h"
#include "Formatter.h"
#include "Torrent.h"
@ -191,9 +193,13 @@ QString TrackerDelegate::getText(TrackerInfo const& inf) const
// hostname
str += inf.st.is_backup ? QStringLiteral("<i>") : QStringLiteral("<b>");
auto const url = QUrl(inf.st.announce);
str += QStringLiteral("%1:%2").arg(url.host()).arg(url.port(80));
auto const announce_url = inf.st.announce.toStdString();
if (auto const parsed = tr_urlParse(announce_url); parsed)
{
str += QStringLiteral("%1:%2")
.arg(QString::fromUtf8(std::data(parsed->host), std::size(parsed->host)))
.arg(parsed->port);
}
str += inf.st.is_backup ? QStringLiteral("</i>") : QStringLiteral("</b>");
// announce & scrape info