From 8ded553835f9516e1adf66a1679311d74daacae9 Mon Sep 17 00:00:00 2001 From: Jean-Marc MEESSEN Date: Fri, 24 Nov 2023 21:22:04 +0100 Subject: [PATCH] Fix POTA reference prefix validation (#109) * Fix POTA reference prefix validation * Update "what's new" for v0.1.7 --- doc/whats_new.md | 8 ++++++-- fleprocess/validate.go | 3 ++- fleprocess/validate_test.go | 10 ++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/doc/whats_new.md b/doc/whats_new.md index 749badc..35c481b 100644 --- a/doc/whats_new.md +++ b/doc/whats_new.md @@ -1,11 +1,15 @@ # What's new? -## v0.1.6 +## v0.1.7 -* Support parsing 5-digit POTA reference numbers by @k0emt (issue #105). +* Fix POTA reference prefix validation (issue #108). ## Previous releases +### v0.1.6 + +* Support parsing 5-digit POTA reference numbers by @k0emt (issue #105). + ### v0.1.5 * Fix "S2S contacts not recognized properly" (issue #78) diff --git a/fleprocess/validate.go b/fleprocess/validate.go index 9511cfe..d6da3d6 100644 --- a/fleprocess/validate.go +++ b/fleprocess/validate.go @@ -51,10 +51,11 @@ func ValidateWwff(inputStr string) (ref, errorMsg string) { return wrongInputStr, errorMsg } -var validPotaRegexp = regexp.MustCompile(`^[\d]{0,1}[A-Z]{1,2}-[\d]{4,5}$`) +var validPotaRegexp = regexp.MustCompile(`^[\d]{0,1}[A-Z]{1,2}[\d]{0,1}-[\d]{4,5}$`) // ValidatePota verifies whether the supplied string is a valid POTA reference. // The syntax is: AA-CCCCC: AA = national prefix, CCCCC = 4 or 5-digit numeric code (e.g. ON-00001). +// Note that the national prefix can start with a number, must have 1 or 2, and can end with a number func ValidatePota(inputStr string) (ref, errorMsg string) { inputStr = strings.ToUpper(strings.TrimSpace(inputStr)) wrongInputStr := "*" + inputStr diff --git a/fleprocess/validate_test.go b/fleprocess/validate_test.go index c9c4302..f46c785 100644 --- a/fleprocess/validate_test.go +++ b/fleprocess/validate_test.go @@ -88,6 +88,16 @@ func TestValidatePota(t *testing.T) { args{inputStr: "4x-0258"}, "4X-0258", "", }, + { + "Good ref (country ref containing a digit)", + args{inputStr: "HB0-0258"}, + "HB0-0258", "", + }, + { + "Good ref (country ref containing a digit)", + args{inputStr: "E7-0258"}, + "E7-0258", "", + }, { "Good ref (5 digit park)", args{inputStr: "k-10177"},