Skip to content

Commit

Permalink
Make plus hyphens regexp a module private variable
Browse files Browse the repository at this point in the history
  • Loading branch information
chankiyu22 committed Sep 24, 2024
1 parent ad361f2 commit e0d60a0
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/lib/infra/sms/accessyou.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,16 @@ func NewAccessYouClient(
}
}

var plusHyphensRegexp = regexp.MustCompile(`[\+\-]+`)

func fixPhoneNumber(phoneNumber string) string {
// Access you phone number should have no + and -
return plusHyphensRegexp.ReplaceAllString(phoneNumber, "")
}

func (n *AccessYouClient) Send(options *SendOptions) (*SendResult, error) {
// Access you phone number should have no +
m1 := regexp.MustCompile(`[\+\-]+`)
to := m1.ReplaceAllString(string(options.To), "")
to := fixPhoneNumber(string(options.To))

respData, sendSMSResponse, err := apis.SendSMS(
n.Client,
n.BaseUrl,
Expand Down

0 comments on commit e0d60a0

Please sign in to comment.