mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add EFC3986
This commit is contained in:
@@ -63,4 +63,40 @@ public class UrlQueryTest {
|
||||
query = URLUtil.buildQuery(map, StandardCharsets.UTF_8);
|
||||
Assert.assertEquals("password=123456&username=SSM", query);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void buildHasNullTest() {
|
||||
Map<String, String> map = new LinkedHashMap<>();
|
||||
map.put(null, "SSM");
|
||||
map.put("password", "123456");
|
||||
String query = URLUtil.buildQuery(map, StandardCharsets.UTF_8);
|
||||
Assert.assertEquals("password=123456", query);
|
||||
|
||||
map = new TreeMap<>();
|
||||
map.put("username", "SSM");
|
||||
map.put("password", "");
|
||||
query = URLUtil.buildQuery(map, StandardCharsets.UTF_8);
|
||||
Assert.assertEquals("password=&username=SSM", query);
|
||||
|
||||
map = new TreeMap<>();
|
||||
map.put("username", "SSM");
|
||||
map.put("password", null);
|
||||
query = URLUtil.buildQuery(map, StandardCharsets.UTF_8);
|
||||
Assert.assertEquals("password&username=SSM", query);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void buildSpecialTest() {
|
||||
Map<String, String> map = new LinkedHashMap<>();
|
||||
map.put("key1&", "SSM");
|
||||
map.put("key2", "123456&");
|
||||
String query = URLUtil.buildQuery(map, StandardCharsets.UTF_8);
|
||||
Assert.assertEquals("key1%26=SSM&key2=123456%26", query);
|
||||
|
||||
map = new TreeMap<>();
|
||||
map.put("username=", "SSM");
|
||||
map.put("password", "=");
|
||||
query = URLUtil.buildQuery(map, StandardCharsets.UTF_8);
|
||||
Assert.assertEquals("password==&username%3D=SSM", query);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user