Fix url replacement for links with no scheme

This commit is contained in:
Garth Vander Houwen 2022-12-24 21:35:50 -08:00
parent be625b693c
commit b7ef87031d

View file

@ -27,10 +27,9 @@ func generateMessageMarkdown (message: String) -> String {
let phone = messageWithMarkdown[range]
messageWithMarkdown = messageWithMarkdown.replacingOccurrences(of: phone, with: "[\(phone)](tel:\(phone))")
} else if match.resultType == .link {
let url = match.url?.absoluteString ?? ""
if url.count > 0 {
messageWithMarkdown = messageWithMarkdown.replacingOccurrences(of: url, with: "[\(String(match.url?.host ?? "Link"))\(String(match.url?.path ?? ""))](\(url))")
}
let url = messageWithMarkdown[range]
let absoluteUrl = match.url?.absoluteString ?? ""
messageWithMarkdown = messageWithMarkdown.replacingOccurrences(of: url, with: "[\(String(match.url?.host ?? "Link"))\(String(match.url?.path ?? ""))](\(absoluteUrl))")
}
}
}