Skip to content

Commit 5873327

Browse files
authored
Merge pull request #202 from North-Two-Five/fix/url-malformed
cant put dots in Retrofits service path
2 parents 2ffeadd + 80a53bc commit 5873327

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

analytics-core/src/main/java/com/segment/analytics/http/SegmentService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77

88
/** REST interface for the Segment API. */
99
public interface SegmentService {
10-
@POST("")
10+
@POST(".")
1111
Call<UploadResponse> upload(@Body Batch batch);
1212
}

analytics/src/main/java/com/segment/analytics/Analytics.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ private Message buildMessage(MessageBuilder builder) {
124124

125125
/** Fluent API for creating {@link Analytics} instances. */
126126
public static class Builder {
127-
private static final HttpUrl DEFAULT_ENDPOINT = HttpUrl.parse("https://api.segment.io");
127+
private static final String DEFAULT_ENDPOINT = "https://api.segment.io";
128+
private static final String DEFAULT_PATH = "/v1/import/";
128129
private static final String DEFAULT_USER_AGENT = "analytics-java/" + AnalyticsVersion.get();
129130

130131
private final String writeKey;
@@ -176,7 +177,7 @@ public Builder endpoint(String endpoint) {
176177
if (endpoint == null || endpoint.trim().length() == 0) {
177178
throw new NullPointerException("endpoint cannot be null or empty.");
178179
}
179-
this.endpoint = HttpUrl.parse(endpoint + "/v1/import/");
180+
this.endpoint = HttpUrl.parse(endpoint + DEFAULT_PATH);
180181
return this;
181182
}
182183

@@ -324,16 +325,17 @@ public Analytics build() {
324325
.create();
325326

326327
if (endpoint == null) {
327-
endpoint = DEFAULT_ENDPOINT;
328+
endpoint = HttpUrl.parse(DEFAULT_ENDPOINT + DEFAULT_PATH);
329+
}
328330

329-
if (uploadURL != null) {
330-
endpoint = uploadURL;
331-
}
331+
if (endpoint == null && uploadURL != null) {
332+
endpoint = uploadURL;
332333
}
333334

334335
if (client == null) {
335336
client = Platform.get().defaultClient();
336337
}
338+
337339
if (log == null) {
338340
log = Log.NONE;
339341
}

0 commit comments

Comments
 (0)