mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
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
f16b9aad0a
commit
bbf5b91675
@@ -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