From c698ddb6d47d192cc4c191072845fc8cd1adc50b Mon Sep 17 00:00:00 2001 From: Nic Pottier Date: Tue, 11 Jun 2019 09:54:41 -0500 Subject: [PATCH] allow two digit shortcodes for tel URNs --- urns/urns.go | 2 +- urns/urns_test.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/urns/urns.go b/urns/urns.go index 64d4dc8..577b701 100644 --- a/urns/urns.go +++ b/urns/urns.go @@ -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}$`) diff --git a/urns/urns_test.go b/urns/urns_test.go index 0d3a303..0a89b62 100644 --- a/urns/urns_test.go +++ b/urns/urns_test.go @@ -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", ""},