Merge branch '4.1.x' into 4.2.x
This commit is contained in:
@@ -195,7 +195,8 @@ public abstract class BeforeFilterFunctions {
|
||||
|
||||
String newPath = uri.getRawPath() + request.uri().getRawPath();
|
||||
|
||||
URI prefixedUri = UriComponentsBuilder.fromUri(request.uri()).replacePath(newPath).build().toUri();
|
||||
URI prefixedUri = UriComponentsBuilder.fromUri(request.uri())
|
||||
.replacePath(newPath).build(true).toUri();
|
||||
return ServerRequest.from(request).uri(prefixedUri).build();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -243,4 +243,32 @@ class BeforeFilterFunctionsTests {
|
||||
.isEqualTo("/modified/path/with%E2%80%93en%E2%80%93dashes%20and%20spaces");
|
||||
}
|
||||
|
||||
@Test
|
||||
void prefixPath() {
|
||||
MockHttpServletRequest servletRequest = MockMvcRequestBuilders
|
||||
.get("http://localhost/get").buildRequest(null);
|
||||
|
||||
ServerRequest request = ServerRequest.create(servletRequest,
|
||||
Collections.emptyList());
|
||||
|
||||
ServerRequest modified = BeforeFilterFunctions.prefixPath("/prefix")
|
||||
.apply(request);
|
||||
|
||||
assertThat(modified.uri().getRawPath()).isEqualTo("/prefix/get");
|
||||
}
|
||||
|
||||
@Test
|
||||
void prefixEncodedPath() {
|
||||
MockHttpServletRequest servletRequest = MockMvcRequestBuilders
|
||||
.get("http://localhost/get/é").buildRequest(null);
|
||||
|
||||
ServerRequest request = ServerRequest.create(servletRequest,
|
||||
Collections.emptyList());
|
||||
|
||||
ServerRequest modified = BeforeFilterFunctions.prefixPath("/pre fix")
|
||||
.apply(request);
|
||||
|
||||
assertThat(modified.uri().getRawPath()).isEqualTo("/pre%20fix/get/%C3%A9");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user