Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
Revert "[sku] append sku token to offline download requests" (#173)
Browse files Browse the repository at this point in the history
This reverts commit c275ad2.
  • Loading branch information
pengdev authored Feb 13, 2020
1 parent 94a7727 commit a8ebcb8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

public class HttpRequestUrl {

private static final StringBuilder requestBuilder = new StringBuilder();

private HttpRequestUrl() {
}

Expand All @@ -24,20 +22,20 @@ private HttpRequestUrl() {
* @return the adapted resource url
*/
public static String buildResourceUrl(@NonNull String host, String resourceUrl, int querySize, boolean offline) {
requestBuilder.setLength(0); // clear previous builder
requestBuilder.append(resourceUrl);
if (isValidMapboxEndpoint(host)) {
if (querySize == 0) {
requestBuilder.append("?");
resourceUrl = resourceUrl + "?";
} else {
requestBuilder.append("&");
resourceUrl = resourceUrl + "&";
}
// Only add SKU token to requests not tagged as "offline" usage.
if (offline) {
requestBuilder.append("offline=true&");
resourceUrl = resourceUrl + "offline=true";
} else {
resourceUrl = resourceUrl + "sku=" + Mapbox.getSkuToken();
}
requestBuilder.append("sku=").append(Mapbox.getSkuToken());
}
return requestBuilder.toString();
return resourceUrl;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ class HttpRequestUrlTest {

@Test
fun testOfflineFlagMapboxCom() {
val expected = "http://mapbox.com/path/of/no/return.pbf?offline=true&sku=foobar"
val expected = "http://mapbox.com/path/of/no/return.pbf?offline=true"
val actual = HttpRequestUrl.buildResourceUrl("mapbox.com", "http://mapbox.com/path/of/no/return.pbf", 0, true)
assertEquals(expected, actual)
}

@Test
fun testOfflineFlagMapboxCn() {
val expected = "http://mapbox.cn/path/of/no/return.pbf?offline=true&sku=foobar"
val expected = "http://mapbox.cn/path/of/no/return.pbf?offline=true"
val actual = HttpRequestUrl.buildResourceUrl("mapbox.cn", "http://mapbox.cn/path/of/no/return.pbf", 0, true)
assertEquals(expected, actual)
}
Expand Down

0 comments on commit a8ebcb8

Please sign in to comment.