GetStream / avatarview-android

✨ Supports loading profile images with fractional styles, shapes, borders, indicators, and initials for Android.
https://getstream.github.io/avatarview-android/
Apache License 2.0
432 stars 26 forks source link

App Gets Crashed when textInitials Contains Multiple spaces in between. For eg :- "Test Name" #46

Open mdhanif-simformsolutions opened 1 year ago

mdhanif-simformsolutions commented 1 year ago

Hi, Thanks for this amazing library, I found one issue here :- When we set textInitials which contains multiple spaces in between at that time app is crashed :- Eg :- When I try to set textInitials = Test Name

So main issue is here :- /** Returns parsed initials from a String. */ internal val String.parseInitials: String @JvmSynthetic inline get() { val textList = trim().split(" ") return when { textList.size > 1 -> "${textList[0][0]}${textList[1][0]}" textList[0].length > 1 -> "${textList[0][0]}${textList[0][1]}" textList[0].isNotEmpty() -> "${textList[0][0]}" else -> "" }.uppercase() }

Now now when `Test     Name` is split it gives [Test, , ,Name] here second and third space is empty