MCPcopy Index your code
hub / github.com/NdoleStudio/httpsms / sanitizeContact

Method sanitizeContact

api/pkg/requests/request.go:37–54  ·  view source on GitHub ↗
(owner string, contact string)

Source from the content-addressed store, hash-verified

35}
36
37func (input *request) sanitizeContact(owner string, contact string) string {
38 contact = strings.TrimSpace(contact)
39
40 if len(contact) < 8 || !input.isDigits(contact) {
41 return contact
42 }
43
44 regionPhoneNumber, err := phonenumbers.Parse(owner, phonenumbers.UNKNOWN_REGION)
45 if err != nil {
46 return contact
47 }
48
49 if number, err := phonenumbers.Parse(contact, phonenumbers.GetRegionCodeForNumber(regionPhoneNumber)); err == nil {
50 contact = phonenumbers.Format(number, phonenumbers.E164)
51 }
52
53 return contact
54}
55
56// sanitizeBool sanitizes a boolean string
57func (input *request) sanitizeBool(value string) string {

Callers 2

SanitizeMethod · 0.80
SanitizeMethod · 0.80

Calls 1

isDigitsMethod · 0.95

Tested by

no test coverage detected