Improve requestUri handling in ReactorUriHelper

Closes gh-36893
This commit is contained in:
rstoyanchev
2026-06-22 11:12:13 +01:00
parent 0e4842062b
commit 34a307d4a6
2 changed files with 18 additions and 0 deletions
@@ -146,6 +146,9 @@ abstract class ReactorUriHelper {
return;
}
}
if (length > 0 && uri.charAt(0) != '/') {
builder.append('/');
}
builder.append(uri);
}
@@ -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/",