fix: Added LOTW badge for Lotw users colored depending on their last upload
This commit is contained in:
+13
-5
@@ -339,17 +339,25 @@ func normalizeCallsign(s string) string {
|
||||
// which can change the DXCC entity (HD5MW/8 → HD8MW → Galápagos, not
|
||||
// Ecuador). This is the same class of rule as KG4 and /MM.
|
||||
if areaDigit != 0 {
|
||||
main = replaceFirstDigit(main, areaDigit)
|
||||
main = replaceAreaDigit(main, areaDigit)
|
||||
}
|
||||
return main
|
||||
}
|
||||
|
||||
// replaceFirstDigit substitutes the first 0-9 digit of a call with d (used to
|
||||
// apply a "/N" call-area change). Returns the call unchanged if it has no digit.
|
||||
func replaceFirstDigit(call string, d byte) string {
|
||||
// replaceAreaDigit substitutes the CALL-AREA digit of a call with d (used to
|
||||
// apply a "/N" call-area change). The area digit is the first digit that comes
|
||||
// AFTER a prefix letter — NOT a leading digit that is part of a digit-first
|
||||
// prefix (7X, 3A, 4X, 9A, 2E…). So 7X2ARA/4 → 7X4ARA (still Algeria, area 4),
|
||||
// NOT 4X2ARA (which is Israel — the old first-digit bug). Returns the call
|
||||
// unchanged if it has no such digit.
|
||||
func replaceAreaDigit(call string, d byte) string {
|
||||
b := []byte(call)
|
||||
seenLetter := false
|
||||
for i := range b {
|
||||
if b[i] >= '0' && b[i] <= '9' {
|
||||
switch {
|
||||
case b[i] >= 'A' && b[i] <= 'Z':
|
||||
seenLetter = true
|
||||
case b[i] >= '0' && b[i] <= '9' && seenLetter:
|
||||
b[i] = d
|
||||
return string(b)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user