aboutsummaryrefslogtreecommitdiff
path: root/src/cryptoidentity.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/cryptoidentity.cpp')
-rw-r--r--src/cryptoidentity.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/cryptoidentity.cpp b/src/cryptoidentity.cpp
index 921a422..2d9db59 100644
--- a/src/cryptoidentity.cpp
+++ b/src/cryptoidentity.cpp
@@ -1,2 +1,31 @@
#include "cryptoidentity.hpp"
+#include <QUrl>
+#include <QRegExp>
+#include <cassert>
+
+bool CryptoIdentity::isHostFiltered(const QUrl &url) const
+{
+ if(this->host_filter.isEmpty())
+ return false;
+
+ QString url_text = url.toString(QUrl::FullyEncoded);
+
+ QRegExp pattern { this->host_filter, Qt::CaseInsensitive, QRegExp::Wildcard };
+
+ return not pattern.exactMatch(url_text);
+}
+
+bool CryptoIdentity::isAutomaticallyEnabledOn(const QUrl &url) const
+{
+ if(this->host_filter.isEmpty())
+ return false;
+ if(not this->auto_enable)
+ return false;
+
+ QString url_text = url.toString(QUrl::FullyEncoded);
+
+ QRegExp pattern { this->host_filter, Qt::CaseInsensitive, QRegExp::Wildcard };
+
+ return pattern.exactMatch(url_text);
+}