move MustCompile regex out of constructor

This commit is contained in:
Joel Wetzell
2026-05-18 18:17:38 -05:00
parent 547bc60ed7
commit 106d7fee10
@@ -27,6 +27,8 @@ type SipDTMFResponse struct {
Digits string
}
var validDTMFRegex = regexp.MustCompile(`^[0-9*#A-Da-d]+$`)
func (srdc *SipResponseDTMFCreate) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
templateData := wrappedPayload
@@ -103,7 +105,7 @@ func init() {
if err != nil {
return nil, err
}
return &SipResponseDTMFCreate{config: config, Digits: digitsTemplate, PreWait: int(preWaitNum), PostWait: int(postWaitNum), validDTMF: regexp.MustCompile(`^[0-9*#A-Da-d]+$`)}, nil
return &SipResponseDTMFCreate{config: config, Digits: digitsTemplate, PreWait: int(preWaitNum), PostWait: int(postWaitNum), validDTMF: validDTMFRegex}, nil
},
})
}