caddyhttp: Very minor optimization to path matcher

If * is in the matcher it will always match so we can just put it first.
This commit is contained in:
Matthew Holt 2022-09-13 11:26:10 -06:00
parent 61c75f74de
commit 20d487be57
No known key found for this signature in database
GPG Key ID: 2A349DD577D586A5
1 changed files with 5 additions and 1 deletions

View File

@ -374,7 +374,11 @@ func (MatchPath) CaddyModule() caddy.ModuleInfo {
// Provision lower-cases the paths in m to ensure case-insensitive matching. // Provision lower-cases the paths in m to ensure case-insensitive matching.
func (m MatchPath) Provision(_ caddy.Context) error { func (m MatchPath) Provision(_ caddy.Context) error {
for i := range m { for i := range m {
// TODO: if m[i] == "*", put it first and delete all others (will always match) if m[i] == "*" && i > 0 {
// will always match, so just put it first
m[0] = m[i]
break
}
m[i] = strings.ToLower(m[i]) m[i] = strings.ToLower(m[i])
} }
return nil return nil