From 15b2811fa53774c7a7ee3d1c814703f0d2f8a292 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Thu, 4 Jun 2020 14:43:37 +0800 Subject: [PATCH] Don't use deprecated QUrl::topLevelDomain() --- src/gui/transferlistfilterswidget.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/gui/transferlistfilterswidget.cpp b/src/gui/transferlistfilterswidget.cpp index 0954d1a8a..ac2616260 100644 --- a/src/gui/transferlistfilterswidget.cpp +++ b/src/gui/transferlistfilterswidget.cpp @@ -599,18 +599,15 @@ int TrackerFiltersList::rowFromTracker(const QString &tracker) const QString TrackerFiltersList::getHost(const QString &tracker) const { - QUrl url(tracker); - QString longHost = url.host(); - QString tld = url.topLevelDomain(); - // We get empty tld when it is invalid or an IPv4/IPv6 address, - // so just return the full host - if (tld.isEmpty()) - return longHost; // We want the domain + tld. Subdomains should be disregarded - int index = longHost.lastIndexOf('.', -(tld.size() + 1)); - if (index == -1) - return longHost; - return longHost.mid(index + 1); + const QUrl url {tracker}; + const QString host {url.host()}; + + // host is in IP format + if (!QHostAddress(host).isNull()) + return host; + + return host.section('.', -2, -1); } QStringList TrackerFiltersList::getHashes(const int row) const