summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/matchers_test.go
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2020-06-16 10:41:37 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2020-06-16 10:41:37 -0600
commit6db3615547b8911ac81dc2b23c1ed8bedbef0fdb (patch)
treef361571f3699ac59b882f30a08756fe9ba828364 /modules/caddyhttp/matchers_test.go
parent32cafbb6309c8d78cc7e2f2a75def9c633944ef8 (diff)
caddyhttp: Enable matching empty query string
Caddyfile syntax: query "" Or a nil matcher in the JSON should also match an empty query string. See https://caddy.community/t/v2-match-empty-query/8708?u=matt
Diffstat (limited to 'modules/caddyhttp/matchers_test.go')
-rw-r--r--modules/caddyhttp/matchers_test.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/modules/caddyhttp/matchers_test.go b/modules/caddyhttp/matchers_test.go
index 9b3a9a8..219ada8 100644
--- a/modules/caddyhttp/matchers_test.go
+++ b/modules/caddyhttp/matchers_test.go
@@ -528,6 +528,24 @@ func TestQueryMatcher(t *testing.T) {
input: "/?someparam",
expect: false,
},
+ {
+ scenario: "nil matcher value should match empty query",
+ match: MatchQuery(nil),
+ input: "/?",
+ expect: true,
+ },
+ {
+ scenario: "nil matcher value should NOT match a non-empty query",
+ match: MatchQuery(nil),
+ input: "/?foo=bar",
+ expect: false,
+ },
+ {
+ scenario: "non-nil matcher should NOT match an empty query",
+ match: MatchQuery{"": []string{}},
+ input: "/?",
+ expect: false,
+ },
} {
u, _ := url.Parse(tc.input)