aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules/caddyhttp/headers/headers.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/caddyhttp/headers/headers.go')
-rw-r--r--modules/caddyhttp/headers/headers.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/modules/caddyhttp/headers/headers.go b/modules/caddyhttp/headers/headers.go
index bdb185f46..a3279d913 100644
--- a/modules/caddyhttp/headers/headers.go
+++ b/modules/caddyhttp/headers/headers.go
@@ -135,13 +135,14 @@ type HeaderOps struct {
func (ops *HeaderOps) Provision(_ caddy.Context) error {
for fieldName, replacements := range ops.Replace {
for i, r := range replacements {
- if r.SearchRegexp != "" {
- re, err := regexp.Compile(r.SearchRegexp)
- if err != nil {
- return fmt.Errorf("replacement %d for header field '%s': %v", i, fieldName, err)
- }
- replacements[i].re = re
+ if r.SearchRegexp == "" {
+ continue
+ }
+ re, err := regexp.Compile(r.SearchRegexp)
+ if err != nil {
+ return fmt.Errorf("replacement %d for header field '%s': %v", i, fieldName, err)
}
+ replacements[i].re = re
}
}
return nil