diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-10-18 14:40:32 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-10-18 14:40:32 +0200 |
commit | 9ab6f6d363f873f0799982c3c0872d38a656ee84 (patch) | |
tree | bf7fba76f36be8d6560fa5914404ae4fb44711ad /lib/urlfilter/filtertree.cpp | |
parent | buildconfig: don't overwrite install prefix by default (diff) | |
download | smolbote-9ab6f6d363f873f0799982c3c0872d38a656ee84.tar.xz |
urlfilter: add Domain class
(#6): Add domain matcher class
Diffstat (limited to 'lib/urlfilter/filtertree.cpp')
-rw-r--r-- | lib/urlfilter/filtertree.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/urlfilter/filtertree.cpp b/lib/urlfilter/filtertree.cpp index 8844a76..8d88140 100644 --- a/lib/urlfilter/filtertree.cpp +++ b/lib/urlfilter/filtertree.cpp @@ -45,7 +45,7 @@ const QStringList FilterTree::branches() const { QStringList branches; for(auto &branch : m_branches) { - branches.append(QString::fromStdString(branch.domain)); + branches.append(branch.domain.host()); } return branches; } @@ -54,7 +54,7 @@ QVector<const FilterLeaf *> FilterTree::match(const QString& domain, const QStri { QVector<const FilterLeaf *> leaves; for(const auto &branch : m_branches) { - if(branch.domain == domain.toStdString()) { + if(branch.domain.matches(QUrl(domain))) { for(const auto leaf : branch.leaves) { if(leaf->match(requestUrl)) { @@ -70,15 +70,15 @@ QVector<const FilterLeaf *> FilterTree::match(const QString& domain, const QStri bool FilterTree::addRule(FilterLeaf *rule, const QString& domain) { for(auto &branch : m_branches) { - if(branch.domain == domain.toStdString()) { + if(branch.domain.matches(QUrl(domain))) { branch.leaves.emplace_back(rule); return true; } } // no branch was found - Branch branch; - branch.domain = domain.toStdString(); + Branch branch(domain); + //branch.domain = domain.toStdString(); // TODO: for some reason, can't add rule here //branch.leaves.emplace_back(rule); m_branches.emplace_back(std::move(branch)); |