mirror of
https://gitee.com/dromara/hutool.git
synced 2025-05-06 05:38:00 +08:00
UrlBuilder的toURI方法将url重复编码
This commit is contained in:
parent
c4a33819b3
commit
0fdec254ed
@ -10,6 +10,7 @@
|
||||
* 【http 】 修复https下可能的Patch、Get请求失效问题(issue#I3Z3DH@Gitee)
|
||||
* 【core 】 修复RandomUtil#randomString 入参length为负数时报错问题(issue#2515@Github)
|
||||
* 【core 】 修复SecureUtil传入null的key抛出异常问题(pr#2521@Github)
|
||||
* 【core 】 修复UrlBuilder的toURI方法将url重复编码(issue#2503@Github)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -544,12 +544,7 @@ public final class UrlBuilder implements Builder<String> {
|
||||
*/
|
||||
public URI toURI() {
|
||||
try {
|
||||
return new URI(
|
||||
getSchemeWithDefault(),
|
||||
getAuthority(),
|
||||
getPathStr(),
|
||||
getQueryStr(),
|
||||
getFragmentEncoded());
|
||||
return toURL().toURI();
|
||||
} catch (URISyntaxException e) {
|
||||
return null;
|
||||
}
|
||||
|
@ -445,4 +445,21 @@ public class UrlBuilderTest {
|
||||
final UrlBuilder of = UrlBuilder.of(url, null);
|
||||
Assert.assertEquals(url.replace("&", "&"), of.toString());
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Test
|
||||
public void issues2503Test() throws URISyntaxException {
|
||||
String duplicate = UrlBuilder.ofHttp("127.0.0.1:8080")
|
||||
.addQuery("param[0].field", "编码")
|
||||
.toURI()
|
||||
.toString();
|
||||
Assert.assertEquals("http://127.0.0.1:8080?param%5B0%5D.field=%E7%BC%96%E7%A0%81", duplicate);
|
||||
|
||||
String normal = UrlBuilder.ofHttp("127.0.0.1:8080")
|
||||
.addQuery("param[0].field", "编码")
|
||||
.toURL()
|
||||
.toURI()
|
||||
.toString();
|
||||
Assert.assertEquals(duplicate, normal);
|
||||
}
|
||||
}
|
||||
|
@ -132,4 +132,10 @@ public class DbTest {
|
||||
return ps;
|
||||
}), new EntityListHandler());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void findWithDotTest() throws SQLException {
|
||||
Db.use().find(Entity.create("user").set("a.b", "1"));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user