diff --git a/middleware/util.go b/middleware/util.go index 09428eb0b..6550341e8 100644 --- a/middleware/util.go +++ b/middleware/util.go @@ -57,7 +57,7 @@ func matchSubdomain(domain, pattern string) bool { return false } } - return false + return len(domComp) == len(patComp) } // https://tip.golang.org/doc/go1.19#:~:text=Read%20no%20longer%20buffers%20random%20data%20obtained%20from%20the%20operating%20system%20between%20calls diff --git a/middleware/util_test.go b/middleware/util_test.go index b54f12627..5d70abc44 100644 --- a/middleware/util_test.go +++ b/middleware/util_test.go @@ -47,6 +47,16 @@ func Test_matchSubdomain(t *testing.T) { domain, pattern string expected bool }{ + { + domain: "http://example.com", + pattern: "http://example.com", + expected: true, + }, + { + domain: "http://example.com", + pattern: "https://example.com", + expected: false, + }, { domain: "http://aaa.example.com", pattern: "http://*.example.com",