Skip to content

Commit d76ee06

Browse files
authored
Collapse multiple spaces in site titles into one (#25094)
* Collapse multiple spaces in site titles into one * Update based on comments * Fix typo
1 parent a4d971e commit d76ee06

File tree

5 files changed

+10
-4
lines changed

5 files changed

+10
-4
lines changed

RELEASE-NOTES.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
* [*] Reader: Keep only one "Search" option in the main sidebar [#25116]
66
* [*] Reader: Fix Send button design in Comments [#25092]
77
* [*] Reader: Add translation support for posts [#25089]
8+
* [*] Reader: Collapse multiple spaces in site titles into one [#25094]
89
* [*] Fix previewing posts on WordPress.com atomic sites [#25045]
910
* [*] Stats: Rename "External Links" to "Clicks" to be consistent with the web [#25090]
1011
* [*] Stats: Fix locations data discrepancy with the web [#25105]
1112

12-
1313
26.5
1414
-----
1515
* [*] Add "Status" field to the "Post Settings" screen to make it easier to move posts from one state to another [#24939]

Sources/WordPressData/Swift/ReaderPost.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ extension ReaderPost {
5252

5353
public func blogNameForDisplay() -> String? {
5454
if let blogName, !blogName.isEmpty {
55-
return blogName
55+
return blogName.replacing(/\s+/, with: " ")
5656
}
5757
return URL(string: blogURL ?? "")?.host
5858
}

Tests/KeystoneTests/Tests/Models/ReaderPostTests.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,10 @@ final class ReaderPostTests: CoreDataTestCase {
2020
XCTAssertEqual(queryItems.first(where: { $0.name == "s" })?.value, Int(50 * UITraitCollection.current.displayScale).description)
2121
XCTAssertEqual(queryItems.first(where: { $0.name == "d" })?.value, "404")
2222
}
23+
24+
func testBlogNameForDisplay() {
25+
let post = NSEntityDescription.insertNewObject(forEntityName: ReaderPost.entityName(), into: mainContext) as! ReaderPost
26+
post.blogName = "t r e f o l o g y"
27+
XCTAssertEqual(post.blogNameForDisplay(), "t r e f o l o g y")
28+
}
2329
}

WordPress/Classes/ViewRelated/Reader/Controllers/ReaderFeedCell.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct ReaderFeedCell: View {
4343

4444
var title: String {
4545
if let title = feed.title?.stringByDecodingXMLCharacters(), !title.isEmpty {
46-
return title
46+
return title.replacing(/\s+/) { _ in " " }
4747
}
4848
return feed.urlForDisplay ?? ""
4949
}

WordPress/Classes/ViewRelated/Reader/Headers/ReaderSiteHeaderView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class ReaderSiteHeaderView: ReaderBaseHeaderView, ReaderStreamHeader {
3434
return
3535
}
3636
headerViewModel.site = siteTopic
37-
headerViewModel.title = siteTopic.title
37+
headerViewModel.title = siteTopic.title.replacing(/\s+/) { _ in " " }
3838
headerViewModel.siteUrl = URL(string: siteTopic.siteURL)?.host ?? ""
3939
headerViewModel.siteDetails = siteTopic.siteDescription
4040
headerViewModel.postCount = siteTopic.postCount.doubleValue.abbreviatedString()

0 commit comments

Comments
 (0)