Merge branch '3.2.x'

See gh-40616
This commit is contained in:
Phillip Webb 2024-05-03 12:31:33 -07:00
commit 3b66eb7bb7
2 changed files with 7 additions and 1 deletions

View File

@ -36,7 +36,7 @@ final class UriPathEncoder {
static String encode(String path) {
byte[] bytes = path.getBytes(StandardCharsets.UTF_8);
for (byte b : bytes) {
if (isAllowed(b)) {
if (!isAllowed(b)) {
return encode(bytes);
}
}

View File

@ -34,4 +34,10 @@ class UriPathEncoderTests {
assertThat(UriPathEncoder.encode("/Z\u00fcrich")).isEqualTo("/Z%C3%BCrich");
}
@Test
void encodePathWhenNoEncodingIsRequiredReturnsSameInstance() {
String path = "/foo/bar";
assertThat(UriPathEncoder.encode(path)).isSameAs(path);
}
}