| 58 | } |
| 59 | |
| 60 | bool checkExpression(std::string_view match_str, const FilterExpression & expression) |
| 61 | { |
| 62 | if (expression.ignore_query_string) |
| 63 | { |
| 64 | const auto * query_string = find_first_symbols<'?'>(match_str.data(), match_str.data() + match_str.size()); |
| 65 | match_str = match_str.substr(0, query_string - match_str.data()); |
| 66 | } |
| 67 | |
| 68 | if (expression.regex) |
| 69 | return checkRegexExpression(match_str, expression.regex); |
| 70 | |
| 71 | if (expression.match_prefix) |
| 72 | { |
| 73 | /// Match the base path itself or any path below it, on a path-segment ('/') boundary. E.g. the |
| 74 | /// base "/api/v1" matches "/api/v1", "/api/v1/" and "/api/v1/write", but not "/api/v1beta". |
| 75 | const std::string_view prefix = expression.value; |
| 76 | return match_str.starts_with(prefix) |
| 77 | && (match_str.size() == prefix.size() || match_str[prefix.size()] == '/'); |
| 78 | } |
| 79 | |
| 80 | return match_str == expression.value; |
| 81 | } |
| 82 | |
| 83 | CompiledRegexPtr compileRegex(const std::string & regex) |
| 84 | { |
no test coverage detected