mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-23 06:29:10 +00:00
Allow null contextPath in ServerHttpRequest.Builder
The builder method required a non-null contextPath while the underlying field, MutatedServerHttpRequest constructor, and RequestPath.parse all accept null and treat it the same as an empty string. Relax the method parameter to @Nullable so callers can clear the context path directly. Closes gh-37099 Signed-off-by: Garvit Joshi <garvitjoshi9@gmail.com>
This commit is contained in:
committed by
rstoyanchev
parent
82cf15c60f
commit
8d4208f030
+10
@@ -194,6 +194,16 @@ class ServerHttpRequestTests {
|
||||
assertThat(mutated.getURI().getRawPath()).isEqualTo("/other/path");
|
||||
}
|
||||
|
||||
@Test
|
||||
void mutateContextPathToNull() throws Exception {
|
||||
ServerHttpRequest request = createRequest("/context/path", "/context");
|
||||
|
||||
ServerHttpRequest mutated = request.mutate().contextPath(null).build();
|
||||
assertThat(mutated.getPath().contextPath().value()).isEmpty();
|
||||
assertThat(mutated.getPath().pathWithinApplication().value()).isEqualTo("/context/path");
|
||||
assertThat(mutated.getURI().getRawPath()).isEqualTo("/context/path");
|
||||
}
|
||||
|
||||
@Test
|
||||
void mutateContextPathWithoutUpdatingPathShouldFail() throws Exception {
|
||||
ServerHttpRequest request = createRequest("/context/path", "/context");
|
||||
|
||||
Reference in New Issue
Block a user