Skip to content

Commit ba95a53

Browse files
BIT-2443: Fix crash caused by extra blank spaces in name (#3395)
1 parent bb6a7af commit ba95a53

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/vault/util/AccountSummaryExtensions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import java.util.Locale
1818
*/
1919
val AccountSummary.initials: String
2020
get() {
21-
val names = this.name.orEmpty().split(" ")
21+
val names = this.name.orEmpty().split(" ").filter { it.isNotBlank() }
2222
return if (names.size >= 2) {
2323
names
2424
.take(2)

app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/vault/util/AccountSummaryExtensionsTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ class AccountSummaryExtensionsTest {
1212

1313
@Suppress("MaxLineLength")
1414
@Test
15-
fun `initials should return the starting letters of the first two words for a multi-word name`() {
15+
fun `initials should return the starting letters of the first two words for a multi-word name and ignore any extra spaces`() {
1616
assertEquals(
1717
"FS",
1818
mockk<AccountSummary> {
19-
every { name } returns "First Second Third"
19+
every { name } returns "First Second Third"
2020
}
2121
.initials,
2222
)

0 commit comments

Comments
 (0)