summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/map/map.go
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2021-10-13 17:58:20 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2021-10-13 17:58:20 -0600
commit95c035060f66577f52158312c75ca379d7ddc21e (patch)
treef1c3cd3f60daaffb88878bbf4ec7af6f51f59a3b /modules/caddyhttp/map/map.go
parentc4790d7f9d48f72254051e5743d00e930928e0c9 (diff)
map: Fix regex mappings
It didn't really make sense how we were doing them before. See https://caddy.community/t/map-directive-and-regular-expressions/13866/6?u=matt
Diffstat (limited to 'modules/caddyhttp/map/map.go')
-rw-r--r--modules/caddyhttp/map/map.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/modules/caddyhttp/map/map.go b/modules/caddyhttp/map/map.go
index a0e0768..670a55b 100644
--- a/modules/caddyhttp/map/map.go
+++ b/modules/caddyhttp/map/map.go
@@ -136,7 +136,11 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhtt
if output := m.Outputs[destIdx]; output == nil {
continue
} else {
- output = m.re.ReplaceAllString(input, m.Outputs[destIdx].(string))
+ var result []byte
+ for _, submatches := range m.re.FindAllStringSubmatchIndex(input, -1) {
+ result = m.re.ExpandString(result, m.Outputs[destIdx].(string), input, submatches)
+ }
+ output = string(result)
return output, true
}
}