Skip to content

Commit

Permalink
Remove colon when scheme missing in builder toString (#4361)
Browse files Browse the repository at this point in the history
  • Loading branch information
yschimke authored Nov 3, 2018
1 parent 70bf8e7 commit 2b0a9f4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions okhttp-tests/src/test/java/okhttp3/HttpUrlTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -779,9 +779,9 @@ HttpUrl parse(String url) {
@Test public void incompleteBuilderToString() {
assertEquals("https:///path",
new HttpUrl.Builder().scheme("https").encodedPath("/path").toString());
assertEquals("://host.com/path",
assertEquals("//host.com/path",
new HttpUrl.Builder().host("host.com").encodedPath("/path").toString());
assertEquals("://host.com:8080/path",
assertEquals("//host.com:8080/path",
new HttpUrl.Builder().host("host.com").encodedPath("/path").port(8080).toString());
}

Expand Down
4 changes: 3 additions & 1 deletion okhttp/src/main/java/okhttp3/HttpUrl.java
Original file line number Diff line number Diff line change
Expand Up @@ -1260,8 +1260,10 @@ public HttpUrl build() {
StringBuilder result = new StringBuilder();
if (scheme != null) {
result.append(scheme);
result.append("://");
} else {
result.append("//");
}
result.append("://");

if (!encodedUsername.isEmpty() || !encodedPassword.isEmpty()) {
result.append(encodedUsername);
Expand Down

0 comments on commit 2b0a9f4

Please sign in to comment.