Added check for expanding already encoded UriComponents object

This commit is contained in:
Arjen Poutsma
2011-11-02 11:49:45 +00:00
parent 8337f4bf20
commit e8dd35ce5e
2 changed files with 7 additions and 0 deletions

View File

@@ -336,6 +336,8 @@ public final class UriComponents {
}
private UriComponents expandInternal(UriTemplateVariables uriVariables) {
Assert.state(!encoded, "Cannot expand an already encoded UriComponents object");
String expandedScheme = expandUriComponent(this.scheme, uriVariables);
String expandedUserInfo = expandUriComponent(this.userInfo, uriVariables);
String expandedHost = expandUriComponent(this.host, uriVariables);

View File

@@ -54,4 +54,9 @@ public class UriComponentsTests {
assertEquals("http://example.com/1 2 3 4", uriComponents.toUriString());
}
@Test(expected = IllegalStateException.class)
public void expandEncoded() {
UriComponentsBuilder.fromPath("/{foo}").build().encode().expand("bar");
}
}