Added check for expanding already encoded UriComponents object

master
Arjen Poutsma 13 years ago
parent 8337f4bf20
commit e8dd35ce5e
  1. 2
      org.springframework.web/src/main/java/org/springframework/web/util/UriComponents.java
  2. 5
      org.springframework.web/src/test/java/org/springframework/web/util/UriComponentsTests.java

@ -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);

@ -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");
}
}

Loading…
Cancel
Save