blob: fde8ae4a5df03c944079ab7809fd4710c8d5cf40 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
package com.mapbox.mapboxsdk.http;
public class HttpRequestUrl {
private HttpRequestUrl() {
}
/**
* Adapts a resource request url based on the host and query size.
*
* @param host the host used as endpoint
* @param resourceUrl the resource to download
* @param querySize the query size of the resource request
* @return the adapted resource url
*/
public static String buildResourceUrl(String host, String resourceUrl, int querySize) {
if (isValidMapboxEndpoint(host)) {
if (querySize == 0) {
resourceUrl = resourceUrl + "?";
} else {
resourceUrl = resourceUrl + "&";
}
resourceUrl = resourceUrl + "events=true";
}
return resourceUrl;
}
/**
* Validates if the host used as endpoint is a valid Mapbox endpoint.
*
* @param host the host used as endpoint
* @return true if a valid Mapbox endpoint
*/
private static boolean isValidMapboxEndpoint(String host) {
return host.equals("mapbox.com")
|| host.endsWith(".mapbox.com")
|| host.equals("mapbox.cn")
|| host.endsWith(".mapbox.cn");
}
}
|