aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules/caddyhttp/matchers_test.go
diff options
context:
space:
mode:
authorMatthew Holt <[email protected]>2019-11-15 12:47:06 -0700
committerMatthew Holt <[email protected]>2019-11-15 12:47:06 -0700
commit0fc97211abd46098f5953fc6b152aa891060fca5 (patch)
treeaa3f4db1cbd0111bd8916543c60d0eda4334eb63 /modules/caddyhttp/matchers_test.go
parentad90b273dbb13bf45644f39f6c0be1248c943d9a (diff)
downloadcaddy-0fc97211abd46098f5953fc6b152aa891060fca5.tar.gz
caddy-0fc97211abd46098f5953fc6b152aa891060fca5.zip
http: Make path matcher case-insensitive
Adds tests for both the path matcher and host matcher for case insensitivity. If case sensitivity is required for the path, a regexp matcher can be used instead. This is the v2 equivalent fix of PR #2882.
Diffstat (limited to 'modules/caddyhttp/matchers_test.go')
-rw-r--r--modules/caddyhttp/matchers_test.go32
1 files changed, 31 insertions, 1 deletions
diff --git a/modules/caddyhttp/matchers_test.go b/modules/caddyhttp/matchers_test.go
index 81cb1d097..456942588 100644
--- a/modules/caddyhttp/matchers_test.go
+++ b/modules/caddyhttp/matchers_test.go
@@ -48,6 +48,16 @@ func TestHostMatcher(t *testing.T) {
expect: true,
},
{
+ match: MatchHost{"EXAMPLE.COM"},
+ input: "example.com",
+ expect: true,
+ },
+ {
+ match: MatchHost{"example.com"},
+ input: "EXAMPLE.COM",
+ expect: true,
+ },
+ {
match: MatchHost{"example.com"},
input: "foo.example.com",
expect: false,
@@ -74,6 +84,11 @@ func TestHostMatcher(t *testing.T) {
},
{
match: MatchHost{"*.example.com"},
+ input: "SUB.EXAMPLE.COM",
+ expect: true,
+ },
+ {
+ match: MatchHost{"*.example.com"},
input: "foo.example.com",
expect: true,
},
@@ -174,7 +189,12 @@ func TestPathMatcher(t *testing.T) {
},
{
match: MatchPath{"*.ext"},
- input: "foo.ext",
+ input: "/foo.ext",
+ expect: true,
+ },
+ {
+ match: MatchPath{"*.php"},
+ input: "/index.PHP",
expect: true,
},
{
@@ -192,6 +212,16 @@ func TestPathMatcher(t *testing.T) {
input: "/foo/bar/bam",
expect: false,
},
+ {
+ match: MatchPath{"/foo"},
+ input: "/FOO",
+ expect: true,
+ },
+ {
+ match: MatchPath{"/foo/bar.txt"},
+ input: "/foo/BAR.txt",
+ expect: true,
+ },
} {
req := &http.Request{URL: &url.URL{Path: tc.input}}
actual := tc.match.Match(req)