From 14f9662f9cc0f93e88d5efbbaf10de79070bea93 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Fri, 6 Sep 2019 12:36:45 -0600 Subject: Various fixes/tweaks to HTTP placeholder variables and file matching - Rename http.var.* -> http.vars.* to be more consistent - Prefixing a path matcher with * now invokes simple suffix matching - Handlers and matchers that need a root path default to {http.vars.root} - Clean replacer output on the file matcher's file selection suffix --- modules/caddyhttp/matchers.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'modules/caddyhttp/matchers.go') diff --git a/modules/caddyhttp/matchers.go b/modules/caddyhttp/matchers.go index 2ddefd0..7fc8aea 100644 --- a/modules/caddyhttp/matchers.go +++ b/modules/caddyhttp/matchers.go @@ -22,7 +22,6 @@ import ( "net/http" "net/textproto" "net/url" - "path" "path/filepath" "regexp" "strings" @@ -151,12 +150,13 @@ func (MatchPath) CaddyModule() caddy.ModuleInfo { // Match returns true if r matches m. func (m MatchPath) Match(r *http.Request) bool { for _, matchPath := range m { - compare := r.URL.Path + // as a special case, if the first character is a + // wildcard, treat it as a quick suffix match if strings.HasPrefix(matchPath, "*") { - compare = path.Base(compare) + return strings.HasSuffix(r.URL.Path, matchPath[1:]) } // can ignore error here because we can't handle it anyway - matches, _ := filepath.Match(matchPath, compare) + matches, _ := filepath.Match(matchPath, r.URL.Path) if matches { return true } -- cgit v1.2.3