Skip to content

Commit a57f890

Browse files
ranjitc5kdavisk6
authored andcommitted
Avoided url appending with slash when matrix parameter exists (#999)
* Avoided url appending with slash when matrix parameter exists * Added UT to cover url appending with slash when matrix parameter exists
1 parent 9519b3d commit a57f890

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

core/src/main/java/feign/RequestTemplate.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,8 @@ public RequestTemplate uri(String uri, boolean append) {
409409
} else if ((!uri.isEmpty()
410410
&& !uri.startsWith("/")
411411
&& !uri.startsWith("{")
412-
&& !uri.startsWith("?"))) {
412+
&& !uri.startsWith("?")
413+
&& !uri.startsWith(";"))) {
413414
/* if the start of the url is a literal, it must begin with a slash. */
414415
uri = "/" + uri;
415416
}

core/src/test/java/feign/RequestTemplateTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,4 +481,12 @@ public void fragmentShouldNotBeEncodedInTarget() {
481481

482482
assertThat(template.url()).isEqualTo("https://example.com/path?key1=value1#fragment");
483483
}
484+
485+
@Test
486+
public void slashShouldNotBeAppendedForMatrixParams() {
487+
RequestTemplate template =
488+
new RequestTemplate().method(HttpMethod.GET).uri("/path;key1=value1;key2=value2", true);
489+
490+
assertThat(template.url()).isEqualTo("/path;key1=value1;key2=value2");
491+
}
484492
}

0 commit comments

Comments
 (0)