Foundations(iOS Sourceset): Provide implementation for fastFindURLs(). Make a test for it.

This commit is contained in:
KotlinGeekDev
2026-01-26 16:56:11 +01:00
parent 893d363a03
commit 94a5237eaa
3 changed files with 72 additions and 1 deletions
@@ -0,0 +1,21 @@
//
// Created by NullDev on 20/01/2026.
//
import Foundation
@objcMembers public class UrlDetector: NSObject {
public func findURLs(text: String) -> [String] {
var links = [String]()
let detector = try! NSDataDetector(types: NSTextCheckingResult.CheckingType.link.rawValue)
let matches = detector.matches(in: text, options: [], range: NSRange(location: 0, length: text.utf16.count))
for match in matches {
guard let range = Range(match.range, in: text) else { continue }
let url = text[range]
links.append(String(url))
}
return links
}
}