Skip to content

Commit b173d6d

Browse files
committed
Collapse multiple spaces in site titles into one
1 parent 54b6b99 commit b173d6d

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

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+/) { _ in " " }
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 testBlogNameorDisplay() {
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.blogName, "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)