Skip to content

Commit

Permalink
allow two digit shortcodes for tel URNs
Browse files Browse the repository at this point in the history
  • Loading branch information
nicpottier committed Jun 11, 2019
1 parent 5682129 commit c698ddb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion urns/urns.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func IsValidScheme(scheme string) bool {
}

var nonTelCharsRegex = regexp.MustCompile(`[^0-9a-z]`)
var telRegex = regexp.MustCompile(`^\+?[a-zA-Z0-9]{3,64}$`)
var telRegex = regexp.MustCompile(`^\+?[a-zA-Z0-9]{2,64}$`)
var twitterHandleRegex = regexp.MustCompile(`^[a-zA-Z0-9_]{1,15}$`)
var emailRegex = regexp.MustCompile(`^[^\s@]+@[^\s@]+$`)
var viberRegex = regexp.MustCompile(`^[a-zA-Z0-9_=/+]{1,24}$`)
Expand Down
3 changes: 2 additions & 1 deletion urns/urns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,13 @@ func TestValidate(t *testing.T) {
{"tel:+250788383383", ""},
{"tel:+250123", ""},
{"tel:1337", ""},
{"tel:13", ""}, // two digit shortcodes are a thing
{"tel:PRIZES", ""},
{"tel:cellbroadcastchannel50", ""},

// invalid tel numbers
{"tel:07883 83383", "invalid tel number"}, // can't have spaces
{"tel:12", "invalid tel number"}, // too short
{"tel:1", "invalid tel number"}, // too short

// twitter handles
{"twitter:jimmyjo", ""},
Expand Down

0 comments on commit c698ddb

Please sign in to comment.