#1154 - WebFlux Link creation starts with clean query parameters.
We now explicitly remove all query parameters from the base URI we use when creating links from method names.
This commit is contained in:
@@ -255,7 +255,8 @@ public class WebFluxLinkBuilder extends TemplateVariableAwareLinkBuilderSupport<
|
||||
PathContainer contextPath = request.getPath().contextPath();
|
||||
|
||||
return UriComponentsBuilder.fromHttpRequest(request) //
|
||||
.replacePath(contextPath.toString());
|
||||
.replacePath(contextPath.toString()) //
|
||||
.replaceQuery("");
|
||||
}
|
||||
|
||||
private static Mono<WebFluxLinkBuilder> linkToInternal(Object invocation) {
|
||||
|
||||
@@ -214,6 +214,19 @@ class WebFluxLinkBuilderTest {
|
||||
});
|
||||
}
|
||||
|
||||
@Test // #1152
|
||||
void removesIncomingQueryParameters() {
|
||||
|
||||
MockServerHttpRequest request = MockServerHttpRequest.get("http://localhost:8080/api?some=parameter") //
|
||||
.build();
|
||||
|
||||
WebFluxLink link = linkTo(methodOn(TestController.class).deep()).withSelfRel();
|
||||
|
||||
verify(request, link, result -> {
|
||||
assertThat(result.getHref()).endsWith("/api/employees");
|
||||
});
|
||||
}
|
||||
|
||||
private void verify(@Nullable MockServerHttpRequest request, WebFluxLink link, Consumer<Link> verifications) {
|
||||
|
||||
Mono<Link> mono = link.toMono();
|
||||
|
||||
Reference in New Issue
Block a user