Skip to content

Commit 76eeecd

Browse files
author
Jan Guegel
committed
use recommended snippet from naveensingh
1 parent 75f7683 commit 76eeecd

File tree

1 file changed

+3
-1
lines changed
  • commons/src/main/kotlin/org/fossify/commons/models/contacts

1 file changed

+3
-1
lines changed

commons/src/main/kotlin/org/fossify/commons/models/contacts/Contact.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ data class Contact(
173173
}
174174
val lastPart = if (startWithSurname) firstMiddle else surname
175175
val suffixComma = if (suffix.isEmpty()) "" else ", $suffix"
176-
val fullName = "$prefix $firstPart $lastPart$suffixComma".trim().replace(Regex("\\s+"), " ")
176+
val fullName = listOfNotNull(prefix, firstPart, "$lastPart$suffixComma")
177+
.filter { it.isNotBlank() }
178+
.joinToString(" ")
177179
val organization = getFullCompany()
178180
val email = emails.firstOrNull()?.value?.trim()
179181
val phoneNumber = phoneNumbers.firstOrNull()?.normalizedNumber

0 commit comments

Comments
 (0)