From 20d487be573424e7647b5a157754f6e284554e23 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Tue, 13 Sep 2022 11:26:10 -0600 Subject: [PATCH] caddyhttp: Very minor optimization to path matcher If * is in the matcher it will always match so we can just put it first. --- modules/caddyhttp/matchers.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/caddyhttp/matchers.go b/modules/caddyhttp/matchers.go index 3d5791f7..a01f8f98 100644 --- a/modules/caddyhttp/matchers.go +++ b/modules/caddyhttp/matchers.go @@ -374,7 +374,11 @@ func (MatchPath) CaddyModule() caddy.ModuleInfo { // Provision lower-cases the paths in m to ensure case-insensitive matching. func (m MatchPath) Provision(_ caddy.Context) error { 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]) } return nil