I am currently implementing SNA in a project and have found that during testing that the SNA SDK will crash in the lower level network code if the snaURL string isn't a valid networking URL. The check that happens here:
|
guard let url = URL(string: url) else { |
|
onComplete(.failure(.invalidUrl)) |
|
return |
|
} |
really only fails if the string is an empty string. Anything else and the URL is happily created. Later on down the line when it tries to get the host and such, it returns nil and that causes crashes deep in the network code.
To handle this in my current code, I am checking to see that the SNA url I am getting back is valid, and if it is not, I pass an empty string down to the SNA SDK so that it will fire the .invalidUrl error.
It would be helpful if the validation here included a few more items, such as:
guard
let url = URL(string: url),
let scheme = url.scheme?.lowercased(),
scheme.hasPrefix("http"),
url.host != nil = else {
onComplete(.failure(.invalidUrl))
return
}
I am currently implementing SNA in a project and have found that during testing that the SNA SDK will crash in the lower level network code if the snaURL string isn't a valid networking URL. The check that happens here:
twilio-verify-sna-ios/Sources/Domain/RequestManager/RequestManager.swift
Lines 92 to 95 in 1bdccee
really only fails if the string is an empty string. Anything else and the
URLis happily created. Later on down the line when it tries to get the host and such, it returnsniland that causes crashes deep in the network code.To handle this in my current code, I am checking to see that the SNA url I am getting back is valid, and if it is not, I pass an empty string down to the SNA SDK so that it will fire the
.invalidUrlerror.It would be helpful if the validation here included a few more items, such as: