Skip to content

Commit

Permalink
Merge pull request #685 from nyaruka/contact_resolve_tweak
Browse files Browse the repository at this point in the history
Add workaround to contact resolve endpoint to deal with invalid phone numbers
  • Loading branch information
rowanseymour authored Nov 3, 2022
2 parents f3dfc58 + 6a03920 commit e793536
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions web/contact/contact.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ func handleResolve(ctx context.Context, rt *runtime.Runtime, r *http.Request) (i

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

// TODO rework normalization to be idempotent because an invalid number like +2621112222 normalizes to
// 2621112222 (invalid) and then normalizes to +12621112222 (valid)
urn = urn.Normalize(string(oa.Env().DefaultCountry()))

if err := urn.Validate(); err != nil {
return errors.Wrapf(err, "URN failed validation"), http.StatusBadRequest, nil
}
Expand Down

0 comments on commit e793536

Please # to comment.