diff options
author | Julian Rex <julian.rex@mapbox.com> | 2019-11-20 12:44:39 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-20 12:44:39 -0500 |
commit | 21af0ff4878f23033dd17d0e9bb5297070a5e39d (patch) | |
tree | 7de82a112ff3f72ab356a17efecc608074fc31c1 | |
parent | 03b7fe33260b7be4f03f47c1badc2c1601df4b0e (diff) | |
download | qtlocation-mapboxgl-21af0ff4878f23033dd17d0e9bb5297070a5e39d.tar.gz |
[ios] Refactor host checks (#15948)
-rw-r--r-- | platform/darwin/src/http_file_source.mm | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/platform/darwin/src/http_file_source.mm b/platform/darwin/src/http_file_source.mm index b0f69f4a7f..dbf92aa462 100644 --- a/platform/darwin/src/http_file_source.mm +++ b/platform/darwin/src/http_file_source.mm @@ -196,13 +196,20 @@ HTTPFileSource::HTTPFileSource() HTTPFileSource::~HTTPFileSource() = default; MGL_EXPORT +BOOL isValidMapboxEndpoint(NSURL *url) { + return ([url.host isEqualToString:@"mapbox.com"] || + [url.host hasSuffix:@".mapbox.com"] || + [url.host isEqualToString:@"mapbox.cn"] || + [url.host hasSuffix:@".mapbox.cn"]); +} + +MGL_EXPORT NSURL *resourceURLWithAccountType(const Resource& resource, NSInteger accountType) { NSURL *url = [NSURL URLWithString:@(resource.url.c_str())]; #if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR - if (accountType == 0 && - ([url.host isEqualToString:@"mapbox.com"] || [url.host hasSuffix:@".mapbox.com"])) { + if (accountType == 0 && isValidMapboxEndpoint(url)) { NSURLComponents *components = [NSURLComponents componentsWithURL:url resolvingAgainstBaseURL:NO]; NSMutableArray *queryItems = [NSMutableArray array]; |