Skip to content

Commit 737b18b

Browse files
committed
qt6: ‘const class QUrl’ has no member named ‘topLevelDomain’
- https://bugreports.qt.io/browse/QTBUG-80308
1 parent de7740d commit 737b18b

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/core/UserScript.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,12 @@ bool UserScript::checkUrl(const QUrl &url, const QStringList &rules) const
424424
return QRegularExpression(rule.mid(1, rule.length() - 2)).match(url.url()).hasMatch();
425425
}
426426

427+
#if QT_VERSION < 0x060000 // qt6: ‘const class QUrl’ has no member named ‘topLevelDomain’
427428
if (rule.contains(QLatin1String(".tld"), Qt::CaseInsensitive))
428429
{
429430
rule.replace(QLatin1String(".tld"), Utils::getTopLevelDomain(url), Qt::CaseInsensitive);
430431
}
432+
#endif
431433

432434
bool useExactMatch(true);
433435

src/core/Utils.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,10 +550,12 @@ QString normalizePath(const QString &path)
550550
return path;
551551
}
552552

553+
#if QT_VERSION < 0x060000 // qt6: ‘const class QUrl’ has no member named ‘topLevelDomain’
553554
QString getTopLevelDomain(const QUrl &url)
554555
{
555556
return url.topLevelDomain();
556557
}
558+
#endif
557559

558560
QString getStandardLocation(QStandardPaths::StandardLocation type)
559561
{
@@ -802,6 +804,7 @@ bool ensureDirectoryExists(const QString &path)
802804

803805
bool isDomainTheSame(const QUrl &firstUrl, const QUrl &secondUrl)
804806
{
807+
#if QT_VERSION < 0x060000 // qt6: 'topLevelDomain()' is no more; port to 'qIsEffectiveTLD()'?
805808
const QString firstTld(getTopLevelDomain(firstUrl));
806809
const QString secondTld(getTopLevelDomain(secondUrl));
807810

@@ -817,6 +820,8 @@ bool isDomainTheSame(const QUrl &firstUrl, const QUrl &secondUrl)
817820
secondDomain.remove((secondDomain.length() - secondTld.length()), secondTld.length());
818821

819822
return firstDomain.section(QLatin1Char('.'), -1) == secondDomain.section(QLatin1Char('.'), -1);
823+
#endif
824+
return false;
820825
}
821826

822827
bool isUrl(const QString &text)

0 commit comments

Comments
 (0)