diff options
-rw-r--r-- | caddyconfig/httpcaddyfile/httptype_test.go | 26 | ||||
-rw-r--r-- | modules/caddyhttp/matchers.go | 2 |
2 files changed, 24 insertions, 4 deletions
diff --git a/caddyconfig/httpcaddyfile/httptype_test.go b/caddyconfig/httpcaddyfile/httptype_test.go index d612cd4..64f0f82 100644 --- a/caddyconfig/httpcaddyfile/httptype_test.go +++ b/caddyconfig/httpcaddyfile/httptype_test.go @@ -6,7 +6,7 @@ import ( "github.com/caddyserver/caddy/v2/caddyconfig/caddyfile" ) -func TestServerType(t *testing.T) { +func TestMatcherSyntax(t *testing.T) { for i, tc := range []struct { input string expectWarn bool @@ -15,7 +15,7 @@ func TestServerType(t *testing.T) { { input: `http://localhost @debug { - query showdebug=1 + query showdebug=1 } `, expectWarn: false, @@ -24,12 +24,32 @@ func TestServerType(t *testing.T) { { input: `http://localhost @debug { - query bad format + query bad format } `, expectWarn: false, expectError: true, }, + { + input: `http://localhost + @debug { + not { + path /somepath* + } + } + `, + expectWarn: false, + expectError: false, + }, + { + input: `http://localhost + @debug { + not path /somepath* + } + `, + expectWarn: false, + expectError: false, + }, } { adapter := caddyfile.Adapter{ diff --git a/modules/caddyhttp/matchers.go b/modules/caddyhttp/matchers.go index f69fc67..f608ccd 100644 --- a/modules/caddyhttp/matchers.go +++ b/modules/caddyhttp/matchers.go @@ -559,7 +559,7 @@ func (m *MatchNot) UnmarshalCaddyfile(d *caddyfile.Dispenser) error { for d.Next() { var mp matcherPair matcherMap := make(map[string]RequestMatcher) - for d.NextBlock(0) { + for d.NextArg() || d.NextBlock(0) { matcherName := d.Val() mod, err := caddy.GetModule("http.matchers." + matcherName) if err != nil { |