aboutsummaryrefslogtreecommitdiff
path: root/lib/urlfilter/domain.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/urlfilter/domain.cpp')
-rw-r--r--lib/urlfilter/domain.cpp65
1 files changed, 0 insertions, 65 deletions
diff --git a/lib/urlfilter/domain.cpp b/lib/urlfilter/domain.cpp
deleted file mode 100644
index 2bfd524..0000000
--- a/lib/urlfilter/domain.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * This file is part of smolbote. It's copyrighted by the contributors recorded
- * in the version control history of the file, available from its original
- * location: https://neueland.iserlohn-fortress.net/gitea/aqua/smolbote
- *
- * SPDX-License-Identifier: GPL-3.0
- */
-
-#include "domain.h"
-
-Domain::Domain(const QString &domain)
- : m_domain(domain)
- , m_hash(qHash(domain, 0))
-{
-}
-
-Domain::Domain(Domain &&other)
- : m_domain(std::move(other.m_domain))
- , m_hash(std::move(other.m_hash))
-{
-}
-
-Domain &Domain::operator=(Domain &&other)
-{
- m_domain = std::move(other.m_domain);
- m_hash = other.m_hash;
- return *this;
-}
-
-bool Domain::matches(const QUrl &url) const
-{
- // empty domain matches all
- if(m_domain.isEmpty() || url.isEmpty())
- return true;
-
- const QString domain = url.host();
-
- // domain and filter are the same
- if(domain == m_domain) {
- return true;
- }
-
- // domain cannot be matched if it doesn't end with filter
- // ex. example2.com isn't matched by example.com
- if(!domain.endsWith(m_domain)) {
- return false;
- }
-
- // match with subdomains
- // ex. subdomain.example.com is matched by example.com
- int index = domain.indexOf(m_domain);
-
- // match if (domain ends with filter) && (filter has been found) and (character before filter is '.')
- return index > 0 && domain[index - 1] == QLatin1Char('.');
-}
-
-bool Domain::matchesExactly(uint hash) const
-{
- return (m_hash == hash);
-}
-
-QString Domain::host() const
-{
- return m_domain;
-}