From cc34337b8ebb61d40ec343cee0fc225a694d3db6 Mon Sep 17 00:00:00 2001 From: Rajat Jain Date: Fri, 29 Jan 2021 01:07:21 +0530 Subject: [PATCH] using Matcher methods --- modules/caddyhttp/map/map.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/modules/caddyhttp/map/map.go b/modules/caddyhttp/map/map.go index a0e07687..eb4c441c 100644 --- a/modules/caddyhttp/map/map.go +++ b/modules/caddyhttp/map/map.go @@ -132,15 +132,19 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhtt // the requested destination/output value for _, m := range h.Mappings { if m.re != nil { - if m.re.MatchString(input) { - if output := m.Outputs[destIdx]; output == nil { - continue - } else { - output = m.re.ReplaceAllString(input, m.Outputs[destIdx].(string)) - return output, true + matchRegexp := caddyhttp.MatchRegexp{Pattern: m.InputRegexp} + matchRegexp.Provision(caddy.Context{}) + err := matchRegexp.Validate() + if err == nil { + if matchRegexp.Match(input, repl) { + if output := m.Outputs[destIdx]; output == nil { + continue + } else { + output = repl.ReplaceAll(m.Outputs[destIdx].(string), "") + return output, true + } } } - continue } if input == m.Input { if output := m.Outputs[destIdx]; output == nil {