MCPcopy
hub / github.com/caddyserver/caddy / isCELConcatCall

Function isCELConcatCall

modules/caddyhttp/celmatcher.go:768–788  ·  view source on GitHub ↗

isCELConcatCall tests whether the expression is a concat function (+) with string, placeholder, or other concat call arguments.

(e ast.Expr)

Source from the content-addressed store, hash-verified

766// isCELConcatCall tests whether the expression is a concat function (+) with string, placeholder, or
767// other concat call arguments.
768func isCELConcatCall(e ast.Expr) bool {
769 switch e.Kind() {
770 case ast.CallKind:
771 call := e.AsCall()
772 if call.Target().Kind() != ast.UnspecifiedExprKind {
773 return false
774 }
775 if call.FunctionName() != operators.Add {
776 return false
777 }
778 for _, arg := range call.Args() {
779 if !isCELStringExpr(arg) {
780 return false
781 }
782 }
783 return true
784 case ast.UnspecifiedExprKind, ast.ComprehensionKind, ast.IdentKind, ast.ListKind, ast.LiteralKind, ast.MapKind, ast.SelectKind, ast.StructKind:
785 // appeasing the linter :)
786 }
787 return false
788}
789
790// isCELStringListLiteral returns whether the expression resolves to a list literal
791// containing only string constants or a placeholder call.

Callers 1

isCELStringExprFunction · 0.70

Calls 2

ArgsMethod · 0.80
isCELStringExprFunction · 0.70

Tested by

no test coverage detected