summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2022-09-13 11:26:10 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2022-09-13 11:26:10 -0600
commit20d487be573424e7647b5a157754f6e284554e23 (patch)
treeaf0422d658e6ad74aebca7ca9c152743ada78ccc /modules
parent61c75f74dec6b0524feef9b24ef8d6005f096b09 (diff)
caddyhttp: Very minor optimization to path matcher
If * is in the matcher it will always match so we can just put it first.
Diffstat (limited to 'modules')
-rw-r--r--modules/caddyhttp/matchers.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/modules/caddyhttp/matchers.go b/modules/caddyhttp/matchers.go
index 3d5791f..a01f8f9 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