This commit is contained in:
Looly
2022-04-08 21:36:45 +08:00
parent 8dbeb7c90f
commit 2b79119c00
8 changed files with 111 additions and 37 deletions

View File

@@ -14,4 +14,16 @@ public class RFC3986Test {
encode = RFC3986.QUERY_PARAM_VALUE.encode("a+1=b", CharsetUtil.CHARSET_UTF_8);
Assert.assertEquals("a+1=b", encode);
}
@Test
public void encodeQueryPercentTest(){
String encode = RFC3986.QUERY_PARAM_VALUE.encode("a=%b", CharsetUtil.CHARSET_UTF_8);
Assert.assertEquals("a=%25b", encode);
}
@Test
public void encodeQueryWithSafeTest(){
String encode = RFC3986.QUERY_PARAM_VALUE.encode("a=%25", CharsetUtil.CHARSET_UTF_8, '%');
Assert.assertEquals("a=%25", encode);
}
}

View File

@@ -405,4 +405,18 @@ public class UrlBuilderTest {
params.forEach(builder::addQuery);
Assert.assertEquals("http://127.0.0.1/devicerecord/list?start=2022-03-31%2000:00:00&end=2022-03-31%2023:59:59&page=1&limit=10", builder.toString());
}
@Test
public void issue2242Test(){
}
@Test
public void issue2243Test(){
// https://github.com/dromara/hutool/issues/2243
// 如果用户已经做了%编码,不应该重复编码
String url = "https://hutool.cn/v1.0?privateNum=%2B8616512884988";
final String s = UrlBuilder.of(url, null).setCharset(CharsetUtil.CHARSET_UTF_8).toString();
Assert.assertEquals(url, s);
}
}