From 9ab6f6d363f873f0799982c3c0872d38a656ee84 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Thu, 18 Oct 2018 14:40:32 +0200 Subject: urlfilter: add Domain class (#6): Add domain matcher class --- lib/urlfilter/filtertree.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/urlfilter/filtertree.cpp') 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 FilterTree::match(const QString& domain, const QStri { QVector 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 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)); -- cgit v1.2.1