This commit is contained in:
Looly 2024-07-04 19:49:36 +08:00
parent 0af4f1cf21
commit 1a1884a04c

View File

@ -518,4 +518,15 @@ public class UrlBuilderTest {
final String build = httpUrl.build(CharsetUtil.UTF_8);
assertEquals("/a:1/b:1/c:1/d:1/", build);
}
@Test
public void issueIAAOC1Test() {
// 使用默认编码后会先decode给定的URL再encode
UrlBuilder urlBuilder = UrlBuilder.ofHttp("http://localhost:9999/getReportDataList?goodsName=工业硫酸98%&conReportTypeId=1");
assertEquals("http://localhost:9999/getReportDataList?goodsName=%E5%B7%A5%E4%B8%9A%E7%A1%AB%E9%85%B898%25&conReportTypeId=1", urlBuilder.build());
// 不指定编码则保持原字符串
urlBuilder = UrlBuilder.ofHttp("http://localhost:9999/getReportDataList?goodsName=工业硫酸98%&conReportTypeId=1", null);
assertEquals("http://localhost:9999/getReportDataList?goodsName=工业硫酸98%&conReportTypeId=1", urlBuilder.build());
}
}