summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/matchers.go
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2019-09-06 12:36:45 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2019-09-06 12:36:45 -0600
commit14f9662f9cc0f93e88d5efbbaf10de79070bea93 (patch)
tree060655e7cc8369f6572df607d99d5f912f475d0f /modules/caddyhttp/matchers.go
parent21d7b662e76feeb506cae9a616d92d85326566bd (diff)
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
Diffstat (limited to 'modules/caddyhttp/matchers.go')
-rw-r--r--modules/caddyhttp/matchers.go8
1 files changed, 4 insertions, 4 deletions
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
}