fix(lookup): QRZ Name is the first name, not first + surname
A log greets an operator; it does not address an envelope. "Robert Smith" filled the Name field with something no one would ever send on the air, and it is the first name that gets used when the contact is answered. So fname alone, with the surname kept only as a last resort for a record that has no first name at all — better a surname than an empty field. The nickname option now falls back to the first name too, which is what it should have done from the start. joinName went with it: nothing composed a name any more.
This commit is contained in:
+15
-17
@@ -220,19 +220,6 @@ func composeQRZAddress(addr1, addr2, zip, country string) string {
|
||||
return strings.Join(parts, ", ")
|
||||
}
|
||||
|
||||
func joinName(first, last string) string {
|
||||
first = strings.TrimSpace(first)
|
||||
last = strings.TrimSpace(last)
|
||||
switch {
|
||||
case first != "" && last != "":
|
||||
return first + " " + last
|
||||
case first != "":
|
||||
return first
|
||||
default:
|
||||
return last
|
||||
}
|
||||
}
|
||||
|
||||
func firstNonEmpty(s ...string) string {
|
||||
for _, v := range s {
|
||||
v = strings.TrimSpace(v)
|
||||
@@ -245,14 +232,25 @@ func firstNonEmpty(s ...string) string {
|
||||
|
||||
// qrzName picks what goes in the log's Name field.
|
||||
//
|
||||
// The nickname is only taken when the operator asked for it AND QRZ has one —
|
||||
// a blank nickname must never blank the name, which is the whole reason this is
|
||||
// a fallback rather than a swap.
|
||||
// The FIRST name only. A log greets an operator, it does not address an
|
||||
// envelope: "Robert" is what goes out on the air, and "Robert Smith" filled the
|
||||
// field with something no one would ever send. The surname stays available in
|
||||
// the record; it simply is not the name of the contact.
|
||||
//
|
||||
// The nickname is taken ahead of it when the operator asked for that AND QRZ
|
||||
// has one — a blank nickname must never blank the name, which is the whole
|
||||
// reason this is a fallback rather than a swap.
|
||||
//
|
||||
// The surname is the last resort: a record with no first name at all is better
|
||||
// answered with a surname than with nothing.
|
||||
func qrzName(preferNickname bool, nickname, fname, name string) string {
|
||||
if preferNickname {
|
||||
if n := strings.TrimSpace(nickname); n != "" {
|
||||
return n
|
||||
}
|
||||
}
|
||||
return joinName(fname, name)
|
||||
if f := strings.TrimSpace(fname); f != "" {
|
||||
return f
|
||||
}
|
||||
return strings.TrimSpace(name)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user