Add assertion failure

This commit is contained in:
Aliona 2018-07-11 17:23:05 +03:00
parent b856a2f65e
commit 0d0ae71916
1 changed files with 7 additions and 7 deletions

View File

@ -59,19 +59,19 @@ public struct NetworkServiceConfiguration {
sessionConfiguration.timeoutIntervalForResource = timeoutInterval
sessionConfiguration.httpAdditionalHeaders = additionalHttpHeaders
let urlKey = String.parseHost(from: baseUrl)
let urlKey = baseUrl.parseHost()
serverTrustPolicies = [urlKey: .disableEvaluation]
}
}
private extension String {
static func parseHost(from string: String) -> String {
return URL(string: string)?.host ?? string
.replacingOccurrences(of: "https://", with: "")
.replacingOccurrences(of: "http://", with: "")
.components(separatedBy: "/")
.first ?? ""
func parseHost() -> String {
guard let host = URL(string: self)?.host else {
assertionFailure("Cannot detect host for base URL")
return ""
}
return host
}
}