Repository: caddyserver/caddy (language: go)

Issue:
Duplicate strings.Count in path matcher
Hi,

Unless I'm mistaken there's a redundant count in this check: 

https://github.com/caddyserver/caddy/blob/f4840cfeb85ac33d29a1ab88d474750041a98733/modules/caddyhttp/matchers.go#L457-L460

if it's indeed a mistake I'll do a PR ASAP.


Discussion / hints:
Oh the second one is there in case the first one fails.

...

j/k. Would happily accept a PR. Thanks!

Fix patch:
diff --git a/modules/caddyhttp/matchers.go b/modules/caddyhttp/matchers.go
index 7a0c47e678f..6e770c5e677 100644
--- a/modules/caddyhttp/matchers.go
+++ b/modules/caddyhttp/matchers.go
@@ -456,8 +456,7 @@ func (m MatchPath) Match(r *http.Request) bool {
 		// treat it as a fast substring match
 		if strings.Count(matchPattern, "*") == 2 &&
 			strings.HasPrefix(matchPattern, "*") &&
-			strings.HasSuffix(matchPattern, "*") &&
-			strings.Count(matchPattern, "*") == 2 {
+			strings.HasSuffix(matchPattern, "*") {
 			if strings.Contains(reqPathForPattern, matchPattern[1:len(matchPattern)-1]) {
 				return true
 			}


Test patch: