mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
Don't use deprecated QUrl::topLevelDomain()
This commit is contained in:
parent
547982c741
commit
15b2811fa5
@ -599,18 +599,15 @@ int TrackerFiltersList::rowFromTracker(const QString &tracker) const
|
|||||||
|
|
||||||
QString TrackerFiltersList::getHost(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
|
// We want the domain + tld. Subdomains should be disregarded
|
||||||
int index = longHost.lastIndexOf('.', -(tld.size() + 1));
|
const QUrl url {tracker};
|
||||||
if (index == -1)
|
const QString host {url.host()};
|
||||||
return longHost;
|
|
||||||
return longHost.mid(index + 1);
|
// host is in IP format
|
||||||
|
if (!QHostAddress(host).isNull())
|
||||||
|
return host;
|
||||||
|
|
||||||
|
return host.section('.', -2, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList TrackerFiltersList::getHashes(const int row) const
|
QStringList TrackerFiltersList::getHashes(const int row) const
|
||||||
|
Loading…
Reference in New Issue
Block a user