feedback-assistant / reports

Open collection of Apple Feedback Assistant reports
228 stars 2 forks source link

FB13497472: EKCalendarItem#url returns invalid URLs in some cases #453

Open sindresorhus opened 10 months ago

sindresorhus commented 10 months ago

Description

The Calendar app allows the user to type in “x.com” (without the scheme) in the URL field of an event. However, “EKCalendarItem#url “ then returns an invalid URL instance, since it’s missing the scheme. I suggest adding a “http://“ scheme if it’s missing. Or at minimum document the fact that “EKCalendarItem#url” can be an invalid URL and that consumers must handle that case.

sindresorhus commented 8 months ago

Apple reply:


If NSURL can represent it, then it’s a valid URL. It's up to the UI client what to do with the URL. Using http:// is not always correct since some calendar clients put a raw telephone number in that field, in which case you would need to use tel: instead.

The calendar app uses Data Detectors to try to guess the right scheme to use when the event doesn’t include one.

sindresorhus commented 8 months ago

My reply:


It’s an invalid URL because it’s parsed into something the user did not intend. When you construct a URL/NSURL instance from ““x.com”, the “x.com” becomes the “path” of the URL, not the “host”. While it’s a valid URL/NSURL instance, it’s not what the user intended and it’s also not a usable URL instance.

To solve your concern with phone numbers, you could have a heuristic that you would only prepend a “http” scheme if the string had a dot “.”, since phone numbers don’t have that.

Behavior like this should be clearly documented, as it’s not obvious.

sindresorhus commented 7 months ago

Apply reply:


Thanks for your input.