summaryrefslogtreecommitdiff
path: root/caddyconfig
diff options
context:
space:
mode:
authorFrancis Lavoie <lavofr@gmail.com>2020-05-05 14:29:21 -0400
committerGitHub <noreply@github.com>2020-05-05 12:29:21 -0600
commit26e559662d677062874afed9775f660f1f5f9c1e (patch)
treebb9855e96790a116c348d4278ead33e6827f5766 /caddyconfig
parent52305618dfc4289e5a3cfcf848450500ef8fa21c (diff)
httpcaddyfile: Support single-line matchers (#3263)
* httpcaddyfile: Support single-line matchers * httpcaddyfile: Add single-line matcher test * httpcaddyfile: Add a matcher syntax adapt test
Diffstat (limited to 'caddyconfig')
-rw-r--r--caddyconfig/httpcaddyfile/httptype.go2
-rw-r--r--caddyconfig/httpcaddyfile/httptype_test.go7
2 files changed, 8 insertions, 1 deletions
diff --git a/caddyconfig/httpcaddyfile/httptype.go b/caddyconfig/httpcaddyfile/httptype.go
index eb067bc..775c062 100644
--- a/caddyconfig/httpcaddyfile/httptype.go
+++ b/caddyconfig/httpcaddyfile/httptype.go
@@ -1001,7 +1001,7 @@ func parseMatcherDefinitions(d *caddyfile.Dispenser, matchers map[string]caddy.M
// handle more than one segment); otherwise, we'd overwrite other
// instances of the matcher in this set
tokensByMatcherName := make(map[string][]caddyfile.Token)
- for nesting := d.Nesting(); d.NextBlock(nesting); {
+ for nesting := d.Nesting(); d.NextArg() || d.NextBlock(nesting); {
matcherName := d.Val()
tokensByMatcherName[matcherName] = append(tokensByMatcherName[matcherName], d.NextSegment()...)
}
diff --git a/caddyconfig/httpcaddyfile/httptype_test.go b/caddyconfig/httpcaddyfile/httptype_test.go
index 64f0f82..1bc2ddf 100644
--- a/caddyconfig/httpcaddyfile/httptype_test.go
+++ b/caddyconfig/httpcaddyfile/httptype_test.go
@@ -50,6 +50,13 @@ func TestMatcherSyntax(t *testing.T) {
expectWarn: false,
expectError: false,
},
+ {
+ input: `http://localhost
+ @debug not path /somepath*
+ `,
+ expectWarn: false,
+ expectError: false,
+ },
} {
adapter := caddyfile.Adapter{