Skip to content

Commit 028ae86

Browse files
ranjitc5kdavisk6
authored andcommitted
Avoided url appending with slash when matrix parameter exists (OpenFeign#999)
* Avoided url appending with slash when matrix parameter exists * Added UT to cover url appending with slash when matrix parameter exists
1 parent d3af6a9 commit 028ae86

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ public RequestTemplate uri(String uri, boolean append) {
406406
if (uri == null) {
407407
uri = "/";
408408
} else if ((!uri.isEmpty() && !uri.startsWith("/") && !uri.startsWith("{")
409-
&& !uri.startsWith("?"))) {
409+
&& !uri.startsWith("?") && !uri.startsWith(";"))) {
410410
/* if the start of the url is a literal, it must begin with a slash. */
411411
uri = "/" + uri;
412412
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,4 +469,13 @@ public void fragmentShouldNotBeEncodedInTarget() {
469469

470470
assertThat(template.url()).isEqualTo("https://example.com/path?key1=value1#fragment");
471471
}
472+
473+
@Test
474+
public void slashShouldNotBeAppendedForMatrixParams(){
475+
RequestTemplate template = new RequestTemplate().method(HttpMethod.GET)
476+
.uri("/path;key1=value1;key2=value2",true);
477+
478+
assertThat(template.url()).isEqualTo("/path;key1=value1;key2=value2");
479+
480+
}
472481
}

0 commit comments

Comments
 (0)