diff --git a/caddyhttp/httpserver/condition.go b/caddyhttp/httpserver/condition.go index 0c65a505..8e33a88e 100644 --- a/caddyhttp/httpserver/condition.go +++ b/caddyhttp/httpserver/condition.go @@ -9,7 +9,7 @@ import ( "github.com/mholt/caddy/caddyfile" ) -// SetupIfMatcher parses `if` or `if_type` in the current dispenser block. +// SetupIfMatcher parses `if` or `if_op` in the current dispenser block. // It returns a RequestMatcher and an error if any. func SetupIfMatcher(c caddyfile.Dispenser) (RequestMatcher, error) { var matcher IfMatcher @@ -195,5 +195,5 @@ func (m IfMatcher) Or(r *http.Request) bool { // IfMatcherKeyword returns if k is a keyword for 'if' config block. func IfMatcherKeyword(k string) bool { - return k == "if" || k == "if_cond" + return k == "if" || k == "if_op" } diff --git a/caddyhttp/httpserver/condition_test.go b/caddyhttp/httpserver/condition_test.go index b64858b7..6fd42f09 100644 --- a/caddyhttp/httpserver/condition_test.go +++ b/caddyhttp/httpserver/condition_test.go @@ -263,3 +263,24 @@ func TestSetupIfMatcher(t *testing.T) { } } } + +func TestIfMatcherKeyword(t *testing.T) { + tests := []struct { + keyword string + expected bool + }{ + {"if", true}, + {"ifs", false}, + {"tls", false}, + {"http", false}, + {"if_op", true}, + {"if_type", false}, + {"if_cond", false}, + } + for i, test := range tests { + valid := IfMatcherKeyword(test.keyword) + if valid != test.expected { + t.Errorf("Test %d: expected %v found %v", i, test.expected, valid) + } + } +}