Skip to content

Commit be82404

Browse files
jvsena42claude
andcommitted
fix: capitalize the first letter of each word of the home profile name
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 5289db3 commit be82404

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

‎Bitkit/Components/Header.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ struct Header: View {
136136
profileAvatar
137137

138138
if let name = pubkyProfile.displayName {
139-
TitleText(name)
139+
TitleText(name.capitalizingFirstLetterOfEachWord)
140140
} else {
141141
TitleText(t("slashtags__your_name_capital"))
142142
}

‎Bitkit/Extensions/String+Utilities.swift‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ extension String {
2020
return value
2121
}
2222

23+
/// Uppercases the first letter of each word and leaves the rest as typed, so "satoshi nakamoto" reads
24+
/// "Satoshi Nakamoto" while "McDonald" keeps its inner capital.
25+
var capitalizingFirstLetterOfEachWord: String {
26+
split(separator: " ", omittingEmptySubsequences: false)
27+
.map { word in word.prefix(1).uppercased() + word.dropFirst() }
28+
.joined(separator: " ")
29+
}
30+
2331
enum EllipsisStyle {
2432
/// Ellipsis in the middle: "ab...de"
2533
case middle

‎BitkitTests/StringUtilitiesTests.swift‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,12 @@ final class StringUtilitiesTests: XCTestCase {
2121
func testRemovingLightningSchemesTrimsWhitespace() {
2222
XCTAssertEqual(" lnurlw:lnurl1example ".removingLightningSchemes(), "lnurl1example")
2323
}
24+
25+
func testCapitalizingFirstLetterOfEachWord() {
26+
XCTAssertEqual("satoshi nakamoto".capitalizingFirstLetterOfEachWord, "Satoshi Nakamoto")
27+
XCTAssertEqual("Satoshi NAKAMOTO".capitalizingFirstLetterOfEachWord, "Satoshi NAKAMOTO")
28+
XCTAssertEqual("ronald mcDonald".capitalizingFirstLetterOfEachWord, "Ronald McDonald")
29+
XCTAssertEqual("élodie van".capitalizingFirstLetterOfEachWord, "Élodie Van")
30+
XCTAssertEqual("".capitalizingFirstLetterOfEachWord, "")
31+
}
2432
}

0 commit comments

Comments
 (0)