Add option to remove path ext in ServletUriCompBuilder

Issue: SPR-10272
This commit is contained in:
Rossen Stoyanchev
2013-08-29 13:38:31 -04:00
parent caa1218d36
commit 50178550eb
2 changed files with 59 additions and 2 deletions

View File

@@ -141,4 +141,22 @@ public class ServletUriComponentsBuilderTests {
}
}
// SPR-10272
@Test
public void pathExtension() {
this.request.setRequestURI("/rest/books/6.json");
ServletUriComponentsBuilder builder = ServletUriComponentsBuilder.fromRequestUri(this.request);
String extension = builder.removePathExtension();
String result = builder.path("/pages/1.{ext}").buildAndExpand(extension).toUriString();
assertEquals("http://localhost/rest/books/6/pages/1.json", result);
}
@Test
public void pathExtensionNone() {
this.request.setRequestURI("/rest/books/6");
ServletUriComponentsBuilder builder = ServletUriComponentsBuilder.fromRequestUri(this.request);
assertNull(builder.removePathExtension());
}
}