Ignore punctuation characters at the end of detected links
- fixes permalink handling when that's the case - prevents deep linking loops between nightly and the main app
This commit is contained in:
committed by
Stefan Ceriu
parent
c4baa988d9
commit
1456c57da0
@@ -191,6 +191,13 @@ struct AttributedStringBuilder: AttributedStringBuilderProtocol {
|
||||
link.insert(contentsOf: "https://", at: link.startIndex)
|
||||
}
|
||||
|
||||
// Don't include punctuation characters at the end of links
|
||||
// e.g `https://element.io/blog:` <- which is a valid link but the wrong place
|
||||
while !link.isEmpty,
|
||||
link.rangeOfCharacter(from: .punctuationCharacters, options: .backwards)?.upperBound == link.endIndex {
|
||||
link = String(link.dropLast())
|
||||
}
|
||||
|
||||
return TextParsingMatch(type: .link(urlString: link), range: match.range)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user