URLComponent doesn't work correctly in Xcode14 beta2

I tested below code:
var c = URLComponents(string: "myscheme://")!
c.host = "my host with space"
let url = c.url!
print(url)
print(url.host)

In Xcode 13.4, the console prints:

myscheme://my%20host%20with%20space
Optional("my host with space")

In Xcode 14, the console prints:

myscheme:
nil

According to URLCompinents.host documentation, it should encode in setter:

The getter for this property removes any percent encoding this component may have (if the component allows percent encoding). Setting this property assumes the subcomponent or component string is not percent encoded and will add percent encoding (if the component allows percent encoding).

Replies

Apple replied from bug reporter:

But couldn't find any documentation or mentioning of this change anywhere. Not in release notes, not in API documentation.

Apple replied from bug reporter:

What was your bug number?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Add a Comment