It is weird to have breaking changing in the bahaviour of the Foundation library APIs depending on the target platform. Before iOS 17 the URL(string:) initializer failed when the string argument was not a valid URL.
let url = URL(string: "invalid url")
// in iOS >=17 this is a valid URL object with value invalid%20url
// in iOS <17, MACOS 13.6, Linux this is nil
Continue reading New behaviour for URL(string:) initializer in iOS 17