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

Function getExpression

src/Server/HTTPHandlerRequestFilter.cpp:102–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100}
101
102FilterExpression getExpression(const std::string & expression, HTTPRequestFilterMatchType match_type, bool ignore_query_string)
103{
104 if (match_type == HTTPRequestFilterMatchType::Prefix)
105 {
106 /// Match the value as a base path on a path-segment boundary (see checkExpression). A trailing '/'
107 /// is stripped here, so "/api/v1/" and "/api/v1" behave the same.
108 std::string_view value = expression;
109 if (value.ends_with('/'))
110 value.remove_suffix(1);
111 return {.value = String{value}, .match_prefix = true, .ignore_query_string = ignore_query_string};
112 }
113
114 /// `Regexp` treats the whole value as a regular expression, while `Full` does so only when the value
115 /// starts with the "regex:" marker.
116 if (match_type == HTTPRequestFilterMatchType::Regexp)
117 return {.value = expression, .regex = compileRegex(expression), .ignore_query_string = ignore_query_string};
118
119 if (startsWith(expression, "regex:"))
120 {
121 auto regex = expression.substr(strlen("regex:"));
122 return {.value = regex, .regex = compileRegex(regex), .ignore_query_string = ignore_query_string};
123 }
124
125 return {.value = expression, .ignore_query_string = ignore_query_string};
126}
127
128}
129

Callers 15

urlFilterFunction · 0.85
fullUrlFilterFunction · 0.85
headersFilterFunction · 0.85
ASTSelectQueryClass · 0.85
withMethod · 0.85
selectMethod · 0.85
tablesMethod · 0.85
aliasesMethod · 0.85
cteAliasesMethod · 0.85
prewhereMethod · 0.85
whereMethod · 0.85
groupByMethod · 0.85

Calls 2

compileRegexFunction · 0.85
startsWithFunction · 0.50

Tested by

no test coverage detected