From 106d7fee109b50f9d846d379cff0c5911598db8e Mon Sep 17 00:00:00 2001 From: Joel Wetzell Date: Mon, 18 May 2026 18:17:38 -0500 Subject: [PATCH] move MustCompile regex out of constructor --- internal/processor/sip-response-dtmf-create.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/processor/sip-response-dtmf-create.go b/internal/processor/sip-response-dtmf-create.go index 95f1f34..9c372d8 100644 --- a/internal/processor/sip-response-dtmf-create.go +++ b/internal/processor/sip-response-dtmf-create.go @@ -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 }, }) }