#1127 - Avoid double encoding in UriTemplate.

We now directly use UriComponentsBuilder in UriTemplate.expand(…) to avoid potential double encoding in the base URI.
This commit is contained in:
Oliver Drotbohm
2019-11-28 11:14:57 +01:00
parent 5f016d6c9e
commit d3ece765bc
2 changed files with 13 additions and 8 deletions

View File

@@ -342,6 +342,13 @@ class UriTemplateUnitTest {
assertThat(expandedTemplate).isEqualTo("/foo?bar=barExpanded&foobar=singleValue");
}
@Test // #1127
void escapesBaseUriProperly() {
assertThat(UriTemplate.of("https://example.org/foo and bar/{baz}").expand("xyzzy"))
.hasToString("https://example.org/foo%20and%20bar/xyzzy");
}
private static void assertVariables(UriTemplate template, TemplateVariable... variables) {
assertVariables(template, Arrays.asList(variables));
}