From f7b57a3246a360396c03ed6f9e9c73bb70003650 Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Fri, 26 Jul 2024 10:27:19 -0700 Subject: [PATCH] Offer fixes suggested by clang-tidy --- include/agent.h | 2 +- src/agent.cpp | 4 +++- src/robots.cpp | 14 +++++++++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/include/agent.h b/include/agent.h index 73e6fdd..f91d89e 100644 --- a/include/agent.h +++ b/include/agent.h @@ -71,7 +71,7 @@ namespace Rep /** * Return true if the URL (either a full URL or a path) is allowed. */ - bool allowed(const std::string& path) const; + bool allowed(const std::string& query) const; std::string str() const; diff --git a/src/agent.cpp b/src/agent.cpp index da7768a..91d0c2a 100644 --- a/src/agent.cpp +++ b/src/agent.cpp @@ -1,6 +1,8 @@ #include #include #include +#include +#include #include "url.h" @@ -92,7 +94,7 @@ namespace Rep } std::string path(escape_url(url)); - if (path.compare("/robots.txt") == 0) + if (path == "/robots.txt") { return true; } diff --git a/src/robots.cpp b/src/robots.cpp index 425f570..b6f90be 100644 --- a/src/robots.cpp +++ b/src/robots.cpp @@ -1,10 +1,14 @@ #include #include #include +#include +#include #include #include +#include #include #include +#include #include "url.h" @@ -76,7 +80,7 @@ namespace Rep agent_map_t::iterator current = agents_.find("*"); while (Robots::getpair(input, key, value)) { - if (key.compare("user-agent") == 0) + if (key =="user-agent") { // Store the user agent string as lowercased std::transform(value.begin(), value.end(), value.begin(), ::tolower); @@ -106,19 +110,19 @@ namespace Rep last_agent = false; } - if (key.compare("sitemap") == 0) + if (key == "sitemap") { sitemaps_.push_back(value); } - else if (key.compare("disallow") == 0) + else if (key == "disallow") { current->second.disallow(value); } - else if (key.compare("allow") == 0) + else if (key == "allow") { current->second.allow(value); } - else if (key.compare("crawl-delay") == 0) + else if (key == "crawl-delay") { try {