-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SR-6527] Linux: Empty URLComponents
does not generate valid URL
#3774
Comments
This is interesting. `urlComponents.url(relativeTo: baseUrl)` uses `urlComponents.string` which evaluates to an empty string (on both Linux and Darwin) and passes it to `URL(string:relativeTo)` which is expected to return nil if `string` is empty. So, the `URLComponents.url(relativeTo)` implementation is a composition of `urlComponents.string` and `URL(string:relativeTo)` both of which are behaving as expected. May be it needs an alternate implementation? |
https://developer.apple.com/documentation/foundation/urlcomponents/1780048-url does not discuss the case of URLComponents value where nothing is defined. May be we should simply add a special case to make the behaviour same as Darwin. |
I wonder whether there's anyone still looking at this issue. |
For anyone who wants platform consistencies with this or similar API, I suggest using this one instead:
The |
Update: I found that the
let urls = nsURLs.compactMap { URL(string: $0.absoluteString) } |
Additional Detail from JIRA
md5: 22fd63926de4684cc07b905a8d223d78
Issue Description:
This code:
generates a valid `URL` on Darwin, but generates `nil` on Linux.
I am using Xcode 9.2 beta 9C34b, Swift 4.0.3
The text was updated successfully, but these errors were encountered: