mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-17 16:39:29 +00:00
Improve requestUri handling in ReactorUriHelper
Closes gh-36893
This commit is contained in:
+3
@@ -146,6 +146,9 @@ abstract class ReactorUriHelper {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (length > 0 && uri.charAt(0) != '/') {
|
||||
builder.append('/');
|
||||
}
|
||||
builder.append(uri);
|
||||
}
|
||||
|
||||
|
||||
+15
@@ -68,6 +68,21 @@ class ReactorUriHelperTests {
|
||||
.hasToString("http://example.org/path");
|
||||
}
|
||||
|
||||
@Test
|
||||
void requestUriWithoutLeadingSlash() throws URISyntaxException {
|
||||
given(nettyRequest.scheme()).willReturn("http");
|
||||
given(nettyRequest.hostName()).willReturn("example.org");
|
||||
given(nettyRequest.hostPort()).willReturn(80);
|
||||
given(nettyRequest.uri()).willReturn("foo/bar");
|
||||
|
||||
URI uri = ReactorUriHelper.createUri(nettyRequest);
|
||||
assertThat(uri).hasScheme("http")
|
||||
.hasHost("example.org")
|
||||
.hasPort(-1)
|
||||
.hasPath("/foo/bar")
|
||||
.hasToString("http://example.org/foo/bar");
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "{displayName}({arguments})")
|
||||
@CsvSource(delimiter='|', value = {
|
||||
"/prefix | /prefix/",
|
||||
|
||||
Reference in New Issue
Block a user