MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / checkExpression

Function checkExpression

src/Server/HTTPHandlerRequestFilter.cpp:60–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58}
59
60bool 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
83CompiledRegexPtr compileRegex(const std::string & regex)
84{

Callers 3

urlFilterFunction · 0.85
fullUrlFilterFunction · 0.85
headersFilterFunction · 0.85

Calls 3

checkRegexExpressionFunction · 0.85
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected