diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2015-05-19 13:44:29 -0700 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2015-05-19 13:44:29 -0700 |
commit | 90b70180c53c2945c10b9520f9e6aa5f4f697ac0 (patch) | |
tree | 112b5b285ab88431bc7e83191d79d604a6e356cb /platform/darwin | |
parent | f74fe69cb85d544e84d6a7ecab1d742ffdf87828 (diff) | |
download | qtlocation-mapboxgl-90b70180c53c2945c10b9520f9e6aa5f4f697ac0.tar.gz |
Compare hostname for adding events=true
ref #1596, #1599
Diffstat (limited to 'platform/darwin')
-rw-r--r-- | platform/darwin/http_request_nsurl.mm | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/platform/darwin/http_request_nsurl.mm b/platform/darwin/http_request_nsurl.mm index 85d5bffb09..bdae9ce517 100644 --- a/platform/darwin/http_request_nsurl.mm +++ b/platform/darwin/http_request_nsurl.mm @@ -153,19 +153,16 @@ void HTTPRequest::start() { @autoreleasepool { - NSMutableString *url = [NSMutableString stringWithString:@(resource.url.c_str())]; - if ([url rangeOfString:@"mapbox.com"].location != NSNotFound) { + NSURL *url = [NSURL URLWithString:@(resource.url.c_str())]; + if ([url.host isEqualToString:@"mapbox.com"] || [url.host hasSuffix:@".mapbox.com"]) { if ([[NSUserDefaults standardUserDefaults] integerForKey:@"MGLMapboxAccountType"] == 0) { - if ([url rangeOfString:@"?"].location == NSNotFound) { - [url appendString:@"?"]; - } else { - [url appendString:@"&"]; - } - [url appendString:@"events=true"]; + NSString *absoluteString = [url.absoluteString stringByAppendingFormat: + (url.query ? @"&%@" : @"?%@"), @"events=true"]; + url = [NSURL URLWithString:absoluteString]; } } - NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]]; + NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url]; if (existingResponse) { if (!existingResponse->etag.empty()) { [req addValue:@(existingResponse->etag.c_str()) forHTTPHeaderField:@"If-None-Match"]; |