swiftnsdatadetector

NSDataDetector do not find .io website


It is not so important but if I use NSDataDetector like here and use it for weblink, I can show all website with .com, .us or even .ca but not for .io If I use http://website.io it is working but if the text is website.io it is not working.

Does someone have a workaround to make it work ?

Sample code working in Playground if you need:

var string = "website.io is not ok but website.com is ok"
var error: NSError?
let detector = NSDataDetector(types: NSTextCheckingType.Link.rawValue, error: &error)
detector?.enumerateMatchesInString(string, options: nil, range: NSMakeRange(0, (string as NSString).length)) { (result, flags, _) in
    println(result)
    println(flags)
}

Output is website.com {25,11}

Missing website.io {0, 10}

Edit:

It is not written on wiki english but on my language, there is some "complacency" domain as .ad .am .cd .co .io .me .mu .nu .tv .je .sr

I just try and only .me works. Is it an Apple limitation for this "still" top-level domains ?


Solution

  • Feel free to file a bug with Apple. However I think it is intentionally omitted because "io" means I in Italian and some people fail to include a space after a dot when finishing a sentence. So if .io got added you'd detect "buon giorno.io non lo so" as a link (it's not). Including http:// or another marker like <> will force the detection.