aboutsummaryrefslogtreecommitdiff
path: root/src/webengine/blockerrule.cpp
blob: 340e8bdfe934c4d4f2cf2dda1c59aff0f6a490a2 (plain)
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 "blockerrule.h"

BlockerRule::BlockerRule(QString rule, QObject *parent) :
    QObject(parent)
{
    QString pattern = rule;

    if(rule.startsWith("@@")) {
        m_exception = true;
        pattern = pattern.remove(0, 2);
    } else {
        m_exception = false;
    }

    ruleExpression.setPattern(pattern);
    m_valid = true;
}

bool BlockerRule::match(const QUrl &url)
{
    return ruleExpression.match(url.toString()).hasMatch();
}

bool BlockerRule::isValid()
{
    return m_valid;
}
bool BlockerRule::isException()
{
    return m_exception;
}