mirror of
https://github.com/yattee/yattee.git
synced 2025-08-06 10:44:06 +00:00
Add tappable description links and timestamps in iOS
This commit is contained in:
@@ -499,6 +499,22 @@ final class PipedAPI: Service, ObservableObject, VideosAPI {
|
||||
range: nil
|
||||
)
|
||||
|
||||
let linkRegex = #"(<a\s+(?:[^>]*?\s+)?href=\"[^"]*\">[^<]*<\/a>)"#
|
||||
let hrefRegex = #"href=\"([^"]*)\">"#
|
||||
guard let hrefRegex = try? NSRegularExpression(pattern: hrefRegex) else { return description }
|
||||
|
||||
description = description.replacingMatches(regex: linkRegex) { matchingGroup in
|
||||
let results = hrefRegex.matches(in: matchingGroup, range: NSRange(matchingGroup.startIndex..., in: matchingGroup))
|
||||
|
||||
if let result = results.first {
|
||||
if let swiftRange = Range(result.range(at: 1), in: matchingGroup) {
|
||||
return String(matchingGroup[swiftRange])
|
||||
}
|
||||
}
|
||||
|
||||
return matchingGroup
|
||||
}
|
||||
|
||||
description = description.replacingOccurrences(
|
||||
of: "<[^>]+>",
|
||||
with: "",
|
||||
|
Reference in New Issue
Block a user