optonaut / ActiveLabel.swift

UILabel drop-in replacement supporting Hashtags (#), Mentions (@) and URLs (http://) written in Swift
MIT License
4.47k stars 686 forks source link

Non RFC 1808 URLs are detected, but unusable #155

Closed ghost closed 5 years ago

ghost commented 7 years ago

when using this library and parsing strings that contain URLs, if they are constructed without a host the convenience URL is not to RFC 1808 spec and fails to have a valid host.

Example: label.text = "www.something.com" ... label.handleURLTap { url in UIApplication.shared.openURL(url) }

The URL is invalid and not openable because of the missing host.

drunknbass-weedmaps commented 7 years ago

I suppose this is more of an issue with openurl

mspasov commented 7 years ago

I second that, the generated URL is invalid and the host in this case is in the path url component. The only way to fix it and get a valid url is to convert it to string, append a schema (http/https) and then generate a new URL object. I think ActiveLabel should do that, prior to passing the url to the block.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.