Skip to content

Commit e793536

Browse files
authored
Merge pull request #685 from nyaruka/contact_resolve_tweak
Add workaround to contact resolve endpoint to deal with invalid phone numbers
2 parents f3dfc58 + 6a03920 commit e793536

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

web/contact/contact.go

+4
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ func handleResolve(ctx context.Context, rt *runtime.Runtime, r *http.Request) (i
197197

198198
urn := request.URN.Normalize(string(oa.Env().DefaultCountry()))
199199

200+
// TODO rework normalization to be idempotent because an invalid number like +2621112222 normalizes to
201+
// 2621112222 (invalid) and then normalizes to +12621112222 (valid)
202+
urn = urn.Normalize(string(oa.Env().DefaultCountry()))
203+
200204
if err := urn.Validate(); err != nil {
201205
return errors.Wrapf(err, "URN failed validation"), http.StatusBadRequest, nil
202206
}

0 commit comments

Comments
 (0)