OLD | NEW |
1 #include <iostream> | 1 #include <iostream> |
2 #include <sstream> | 2 #include <sstream> |
3 | 3 |
4 #include "MatchesCommand.h" | 4 #include "MatchesCommand.h" |
5 | 5 |
6 MatchesCommand::MatchesCommand(AdblockPlus::FilterEngine& filterEngine) | 6 MatchesCommand::MatchesCommand(AdblockPlus::FilterEngine& filterEngine) |
7 : Command("matches"), filterEngine(filterEngine) | 7 : Command("matches"), filterEngine(filterEngine) |
8 { | 8 { |
9 } | 9 } |
10 | 10 |
11 void MatchesCommand::operator()(const std::string& arguments) | 11 void MatchesCommand::operator()(const std::string& arguments) |
12 { | 12 { |
13 std::istringstream argumentStream(arguments); | 13 std::istringstream argumentStream(arguments); |
14 std::string url; | 14 std::string url; |
15 argumentStream >> url; | 15 argumentStream >> url; |
16 std::string contentType; | 16 std::string contentType; |
17 argumentStream >> contentType; | 17 argumentStream >> contentType; |
18 if (!url.size() || !contentType.size()) | 18 std::string documentUrl; |
| 19 argumentStream >> documentUrl; |
| 20 if (!url.size() || !contentType.size() || !documentUrl.size()) |
19 { | 21 { |
20 ShowUsage(); | 22 ShowUsage(); |
21 return; | 23 return; |
22 } | 24 } |
23 | 25 |
24 if (filterEngine.Matches(url, contentType)) | 26 if (filterEngine.Matches(url, contentType, documentUrl)) |
25 std::cout << "Match" << std::endl; | 27 std::cout << "Match" << std::endl; |
26 else | 28 else |
27 std::cout << "No match" << std::endl; | 29 std::cout << "No match" << std::endl; |
28 } | 30 } |
29 | 31 |
30 std::string MatchesCommand::GetDescription() const | 32 std::string MatchesCommand::GetDescription() const |
31 { | 33 { |
32 return "Returns the first filter that matches the supplied URL"; | 34 return "Returns the first filter that matches the supplied URL"; |
33 } | 35 } |
34 | 36 |
35 std::string MatchesCommand::GetUsage() const | 37 std::string MatchesCommand::GetUsage() const |
36 { | 38 { |
37 return name + " URL CONTENT_TYPE"; | 39 return name + " URL CONTENT_TYPE DOCUMENT_URL"; |
38 } | 40 } |
OLD | NEW |