mirror of
https://github.com/writeas/writefreely-swiftui-multiplatform.git
synced 2024-11-15 01:11:02 +00:00
Don't extract lede if the incoming string is empty
This commit is contained in:
parent
c32c67040f
commit
889faf9351
@ -102,21 +102,21 @@ private extension PostListModel {
|
||||
|
||||
var lede: String = ""
|
||||
let sentences = truncatedString.components(separatedBy: terminatingCharacters)
|
||||
let firstSentence = sentences.filter { !$0.isEmpty }[0]
|
||||
|
||||
if truncatedString.count > firstSentence.count {
|
||||
if terminatingPunctuation.contains(truncatedString[firstSentence.endIndex]) {
|
||||
lede = String(truncatedString[...firstSentence.endIndex])
|
||||
} else {
|
||||
lede = firstSentence
|
||||
}
|
||||
} else if truncatedString.count == firstSentence.count {
|
||||
if string.count > 80 {
|
||||
if let endOfStringIndex = truncatedString.lastIndex(of: " ") {
|
||||
lede = truncatedString[..<endOfStringIndex] + "…"
|
||||
if let firstSentence = (sentences.filter { !$0.isEmpty }).first {
|
||||
if truncatedString.count > firstSentence.count {
|
||||
if terminatingPunctuation.contains(truncatedString[firstSentence.endIndex]) {
|
||||
lede = String(truncatedString[...firstSentence.endIndex])
|
||||
} else {
|
||||
lede = firstSentence
|
||||
}
|
||||
} else if truncatedString.count == firstSentence.count {
|
||||
if string.count > 80 {
|
||||
if let endOfStringIndex = truncatedString.lastIndex(of: " ") {
|
||||
lede = truncatedString[..<endOfStringIndex] + "…"
|
||||
}
|
||||
} else {
|
||||
lede = firstSentence
|
||||
}
|
||||
} else {
|
||||
lede = firstSentence
|
||||
}
|
||||
}
|
||||
return lede
|
||||
|
Loading…
Reference in New Issue
Block a user