URL system's handling of international domain names stinks…

Originator:jalkut
Number:rdar://26389710 Date Originated:20-May-2016 08:58 AM
Status:Open Resolved:
Product:Developer Tools Product Version:7.3.1
Classification:UI/Usability Reproducible:Always
 
Summary:
Currently any URL string with an "international domain name" fails initialize NSURL and NSURLComponents. This makes the valuable URL utilities of Foundation unless for general-purpose, user-facing URLs, unless some preliminary step to rationalize the domain name is conducted.

For years I've used Sean Heber's IFUnicodeURL categories on NSURL to help fill this void. This is an unfortunate dependency on shipping both a 3rd party category and library (libidn) to achieve what seems like a very developer and user friendly functionality.

Examining Safari's treatment of such URLs, it has its own extensive domain mapping which achieves the conversion through e.g. -[NSURL _webkit_URLWithUserTypedString:]

Please consider leveraging the work that went into making Safari's URL entry robust and user-friendly, and provide the same or similar functionality to all developers on Mac and iOS.

Steps to Reproduce:
1. Use some international domain name to initialize an NSURL:

[NSURL URLWithString:@"http://💩.la"]

Expected Results:
The URL should "just work" or else the NSURL system should provide some means of translating a "user typed string" into a suitable string for initializing an NSURL.

Actual Results:
The attempted URL initialization returns nil. The 💩 character in the domain name has to be manually transformed by developers, yielding http://xn--ls8h.la/, before the URL can be successfully initialized.

Version:
Version 7.3.1 (7D1012)

Notes:


Configuration:
MacBook Pro 2014 edition 15"

Attachments:

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!