Skip to content

Commit 218eb41

Browse files
committed
Revert the addition of excerpts
1 parent c7c2052 commit 218eb41

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

Modules/Sources/WordPressShared/Utility/GutenbergExcerptGenerator.swift

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,19 @@ public struct GutenbergExcerptGenerator {
1919
.replacingOccurrences(of: "<br\\s*/?>", with: " ", options: .regularExpression)
2020

2121
let range = NSRange(rawText.startIndex..., in: rawText)
22-
var text = (regex?.stringByReplacingMatches(in: rawText, options: [], range: range, withTemplate: "") ?? rawText)
22+
let text = (regex?.stringByReplacingMatches(in: rawText, options: [], range: range, withTemplate: "") ?? rawText)
2323
.stringByDecodingXMLCharacters()
2424
.trimmingCharacters(in: .whitespacesAndNewlines)
2525

26-
if text.count > maxLength {
27-
let truncated = String(text.prefix(maxLength))
28-
text = truncated.lastIndex(of: " ").map { String(truncated[..<$0]) } ?? truncated
26+
// Truncate if needed
27+
if text.count <= maxLength {
28+
return text
2929
}
3030

31-
if text.hasSuffix(".") {
32-
text = String(text.dropLast())
31+
let truncated = String(text.prefix(maxLength))
32+
if let lastSpace = truncated.lastIndex(of: " ") {
33+
return String(truncated[..<lastSpace]) + ""
3334
}
34-
return text + ""
35+
return truncated + ""
3536
}
3637
}

0 commit comments

Comments
 (0)