This commit is contained in:
Looly 2022-08-09 21:40:25 +08:00
parent aa403cbe98
commit 47fe31cf41
4 changed files with 64 additions and 37 deletions

View File

@ -532,12 +532,7 @@ public final class UrlBuilder implements Builder<String> {
*/
public URI toURI() {
try {
return new URI(
getSchemeWithDefault(),
getAuthority(),
getPathStr(),
getQueryStr(),
getFragmentEncoded());
return toURL().toURI();
} catch (final URISyntaxException e) {
return null;
}

View File

@ -445,4 +445,29 @@ public class UrlBuilderTest {
final UrlBuilder of = UrlBuilder.of(url, null);
Assert.assertEquals(url.replace("&amp;", "&"), 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);
}
@Test
public void getAuthorityTest(){
final UrlBuilder builder = UrlBuilder.ofHttp("127.0.0.1:8080")
.addQuery("param[0].field", "编码");
Assert.assertEquals("127.0.0.1:8080", builder.getAuthority());
}
}

View File

@ -21,7 +21,7 @@
<c3p0.version>0.9.5.5</c3p0.version>
<dbcp2.version>2.9.0</dbcp2.version>
<tomcat-jdbc.version>10.0.20</tomcat-jdbc.version>
<druid.version>1.2.9</druid.version>
<druid.version>1.2.11</druid.version>
<hikariCP.version>4.0.3</hikariCP.version>
<sqlite.version>3.36.0.3</sqlite.version>
<!-- 此处固定2.5.x支持到JDK8 -->
@ -123,7 +123,7 @@
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.3.4</version>
<version>42.4.1</version>
<scope>test</scope>
</dependency>
<dependency>

View File

@ -133,4 +133,11 @@ public class DbTest {
return ps;
}), new EntityListHandler());
}
@Test
@Ignore
public void findWithDotTest() {
// 当字段带有点时导致被拆分分别wrap了因此此时关闭自动包装即可
Db.of().disableWrapper().find(Entity.of("user").set("a.b", "1"));
}
}