From 95c035060f66577f52158312c75ca379d7ddc21e Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Wed, 13 Oct 2021 17:58:20 -0600 Subject: 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 --- modules/caddyhttp/map/map.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'modules/caddyhttp/map/map.go') 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 } } -- cgit v1.2.3