Skip to content

Commit

Permalink
Avoided url appending with slash when matrix parameter exists (#999)
Browse files Browse the repository at this point in the history
* Avoided url appending with slash when matrix parameter exists

* Added UT to cover url appending with slash when matrix parameter exists
  • Loading branch information
ranjitc5 authored and kdavisk6 committed Jul 18, 2019
1 parent 9519b3d commit a57f890
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/src/main/java/feign/RequestTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,8 @@ public RequestTemplate uri(String uri, boolean append) {
} else if ((!uri.isEmpty()
&& !uri.startsWith("/")
&& !uri.startsWith("{")
&& !uri.startsWith("?"))) {
&& !uri.startsWith("?")
&& !uri.startsWith(";"))) {
/* if the start of the url is a literal, it must begin with a slash. */
uri = "/" + uri;
}
Expand Down
8 changes: 8 additions & 0 deletions core/src/test/java/feign/RequestTemplateTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -481,4 +481,12 @@ public void fragmentShouldNotBeEncodedInTarget() {

assertThat(template.url()).isEqualTo("https://example.com/path?key1=value1#fragment");
}

@Test
public void slashShouldNotBeAppendedForMatrixParams() {
RequestTemplate template =
new RequestTemplate().method(HttpMethod.GET).uri("/path;key1=value1;key2=value2", true);

assertThat(template.url()).isEqualTo("/path;key1=value1;key2=value2");
}
}

0 comments on commit a57f890

Please sign in to comment.