Skip to content

Commit

Permalink
#1722 - Original test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
odrotbohm committed May 16, 2022
1 parent c102708 commit d8579f5
Showing 1 changed file with 15 additions and 0 deletions.
Expand Up @@ -20,6 +20,7 @@
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.*;

import java.lang.reflect.Method;
import java.nio.charset.Charset;
import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.util.Arrays;
Expand Down Expand Up @@ -61,6 +62,7 @@
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;
import org.springframework.web.util.UriUtils;

/**
* Unit tests for {@link ControllerLinkBuilder}.
Expand Down Expand Up @@ -721,6 +723,13 @@ void ignoresRequestParamMultipartFile() {
});
}

@Test // #1722
void toUriDoesNotDoubleEncodeRequestParameters() {

assertThat(linkTo(methodOn(MyController.class).test("I+will:be+double+encoded")).toUri().toString())
.endsWith(UriUtils.encode("I+will:be+double+encoded", Charset.defaultCharset()));
}

private static UriComponents toComponents(Link link) {
return UriComponentsBuilder.fromUriString(link.expand().getHref()).build();
}
Expand Down Expand Up @@ -918,4 +927,10 @@ public String convert(Sample source) {
}
}

// #1722
static class MyController {
HttpEntity<?> test(@RequestParam("param") String param) {
return null;
}
}
}

0 comments on commit d8579f5

Please sign in to comment.