Fixed url detection

pull/777/head
Morgan Pretty 3 years ago
parent 54ef07402b
commit 54a5827926

@ -1121,11 +1121,15 @@ final class VisibleMessageCell: MessageCell, TappableLabelDelegate {
return [:] return [:]
} }
// Note: The 'String.count' value is based on actual character counts whereas
// NSAttributedString and NSRange are both based on UTF-16 encoded lengths, so
// in order to avoid strings which contain emojis breaking strings which end
// with URLs we need to use the 'String.utf16.count' value when creating the range
return detector return detector
.matches( .matches(
in: attributedText.string, in: attributedText.string,
options: [], options: [],
range: NSRange(location: 0, length: attributedText.string.count) range: NSRange(location: 0, length: attributedText.string.utf16.count)
) )
.reduce(into: [:]) { result, match in .reduce(into: [:]) { result, match in
guard guard

Loading…
Cancel
Save