Skip to content
Snippets Groups Projects
Commit d9d41fa8 authored by Jorge Canizales's avatar Jorge Canizales
Browse files

Prevent storing in the hosts cache with a nil key

parent 95a98ca7
No related branches found
No related tags found
No related merge requests found
...@@ -57,13 +57,16 @@ ...@@ -57,13 +57,16 @@
// Default initializer. // Default initializer.
- (instancetype)initWithAddress:(NSString *)address { - (instancetype)initWithAddress:(NSString *)address {
if (!address) {
return nil;
}
// To provide a default port, we try to interpret the address. If it's just a host name without // To provide a default port, we try to interpret the address. If it's just a host name without
// scheme and without port, we'll use port 443. If it has a scheme, we pass it untouched to the C // scheme and without port, we'll use port 443. If it has a scheme, we pass it untouched to the C
// gRPC library. // gRPC library.
// TODO(jcanizales): Add unit tests for the types of addresses we want to let pass untouched. // TODO(jcanizales): Add unit tests for the types of addresses we want to let pass untouched.
NSURL *hostURL = [NSURL URLWithString:[@"https://" stringByAppendingString:address]]; NSURL *hostURL = [NSURL URLWithString:[@"https://" stringByAppendingString:address]];
if (hostURL && !hostURL.port) { if (hostURL.host && !hostURL.port) {
address = [hostURL.host stringByAppendingString:@":443"]; address = [hostURL.host stringByAppendingString:@":443"];
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment