summaryrefslogtreecommitdiffstats
path: root/src/network/kernel
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2020-04-21 14:27:02 +0200
committerMarc Mutz <marc.mutz@kdab.com>2020-04-26 11:46:16 +0000
commit19bfcdaa43f6ac8841942cb545811eab409f1713 (patch)
tree87bbcca77122c1d90a5b5024a21e14ca0ce6b3b1 /src/network/kernel
parentbc205d81e7c0cc33ee1f5b72c3745c958f3f2aa7 (diff)
Port qIsEffectiveTLD() to QStringView
Also add a piece of documentation that the input needs to be in lower-case (the implementation uses qt_hash to index into a table of TLDs, and qt_hash is case-sensitive). Change-Id: I911c0e2bb0826fc1b0fc01ed60bdfd6e4c0298f2 Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/network/kernel')
-rw-r--r--src/network/kernel/qtldurl.cpp6
-rw-r--r--src/network/kernel/qtldurl_p.h4
2 files changed, 6 insertions, 4 deletions
diff --git a/src/network/kernel/qtldurl.cpp b/src/network/kernel/qtldurl.cpp
index c2f7d1de26..d93407d6f5 100644
--- a/src/network/kernel/qtldurl.cpp
+++ b/src/network/kernel/qtldurl.cpp
@@ -114,9 +114,11 @@ Q_NETWORK_EXPORT QString qTopLevelDomain(const QString &domain)
\internal
Return true if \a domain is a top-level-domain per Qt's copy of the Mozilla public suffix list.
+
+ The \a domain must be in lower-case format (as per QString::toLower()).
*/
-Q_NETWORK_EXPORT bool qIsEffectiveTLD(const QStringRef &domain)
+Q_NETWORK_EXPORT bool qIsEffectiveTLD(QStringView domain)
{
// for domain 'foo.bar.com':
// 1. return if TLD table contains 'foo.bar.com'
@@ -126,7 +128,7 @@ Q_NETWORK_EXPORT bool qIsEffectiveTLD(const QStringRef &domain)
if (containsTLDEntry(domain, ExactMatch)) // 1
return true;
- const int dot = domain.indexOf(QLatin1Char('.'));
+ const auto dot = domain.indexOf(QLatin1Char('.'));
if (dot < 0) // Actual TLD: may be effective if the subject of a wildcard rule:
return containsTLDEntry(QString(QLatin1Char('.') + domain), SuffixMatch);
if (containsTLDEntry(domain.mid(dot), SuffixMatch)) // 2
diff --git a/src/network/kernel/qtldurl_p.h b/src/network/kernel/qtldurl_p.h
index a6948cfd48..c0a07d8e00 100644
--- a/src/network/kernel/qtldurl_p.h
+++ b/src/network/kernel/qtldurl_p.h
@@ -60,10 +60,10 @@ QT_REQUIRE_CONFIG(topleveldomain);
QT_BEGIN_NAMESPACE
Q_NETWORK_EXPORT QString qTopLevelDomain(const QString &domain);
-Q_NETWORK_EXPORT bool qIsEffectiveTLD(const QStringRef &domain);
+Q_NETWORK_EXPORT bool qIsEffectiveTLD(QStringView domain);
inline bool qIsEffectiveTLD(const QString &domain)
{
- return qIsEffectiveTLD(QStringRef(&domain));
+ return qIsEffectiveTLD(qToStringViewIgnoringNull(domain));
}
QT_END_NAMESPACE