aboutsummaryrefslogtreecommitdiff
path: root/src/cryptoidentity.cpp
blob: 2d9db595f824606f595c117c3330ecd341346c35 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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);
}