Skip to content

Commit 981eaf2

Browse files
committed
#323 followup - tidy only and add some extra tests
1 parent 1ac29fe commit 981eaf2

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

http-client/src/main/java/io/avaje/http/client/DUrlBuilder.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@ final class DUrlBuilder implements UrlBuilder {
1515

1616
@Override
1717
public UrlBuilder url(String url) {
18-
1918
if (url.startsWith("http") && url.contains("://")) {
2019
buffer.setLength(0);
2120
}
22-
2321
buffer.append(url);
2422
return this;
2523
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package io.avaje.http.client;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
import static org.assertj.core.api.Assertions.assertThat;
6+
7+
class DUrlBuilderTest {
8+
9+
@Test
10+
void url() {
11+
var uri = UrlBuilder.of("http://foo")
12+
.path("more")
13+
.build();
14+
15+
assertThat(uri).isEqualTo("http://foo/more");
16+
}
17+
18+
@Test
19+
void url_when_httpPrefix() {
20+
var uri = UrlBuilder.of("http://foo")
21+
.url("http://bar")
22+
.path("more")
23+
.build();
24+
25+
assertThat(uri).isEqualTo("http://bar/more");
26+
}
27+
28+
@Test
29+
void path_basic() {
30+
var uri = UrlBuilder.of("http://foo")
31+
.path("more")
32+
.build();
33+
34+
assertThat(uri).isEqualTo("http://foo/more");
35+
}
36+
37+
@Test
38+
void path_when_httpPrefix() {
39+
var uri = UrlBuilder.of("http://foo")
40+
.path("http://bar")
41+
.path("more")
42+
.build();
43+
44+
assertThat(uri).isEqualTo("http://bar/more");
45+
}
46+
}

0 commit comments

Comments
 (0)