mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
add test
This commit is contained in:
parent
0e287161bd
commit
68cfc3db5d
@ -424,11 +424,6 @@ public class UrlBuilderTest {
|
|||||||
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());
|
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
|
@Test
|
||||||
public void issue2243Test() {
|
public void issue2243Test() {
|
||||||
// https://github.com/dromara/hutool/issues/2243
|
// https://github.com/dromara/hutool/issues/2243
|
||||||
|
@ -2,6 +2,8 @@ package cn.hutool.http;
|
|||||||
|
|
||||||
import cn.hutool.core.lang.Console;
|
import cn.hutool.core.lang.Console;
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
|
import cn.hutool.core.net.url.UrlBuilder;
|
||||||
|
import org.junit.Assert;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@ -25,4 +27,19 @@ public class Issue2531Test {
|
|||||||
final HttpResponse execute = request.execute();
|
final HttpResponse execute = request.execute();
|
||||||
Console.log(execute.body());
|
Console.log(execute.body());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void encodePlusTest(){
|
||||||
|
// 根据RFC3986规范,在URL中,"+"是安全字符,所以不会解码也不会编码
|
||||||
|
UrlBuilder builder = UrlBuilder.ofHttp("https://hutool.cn/a=+");
|
||||||
|
Assert.assertEquals("https://hutool.cn/a=+", builder.toString());
|
||||||
|
|
||||||
|
// 由于+为安全字符无需编码,ofHttp方法会把%2B解码为+,但是编码的时候不会编码
|
||||||
|
builder = UrlBuilder.ofHttp("https://hutool.cn/a=%2B");
|
||||||
|
Assert.assertEquals("https://hutool.cn/a=+", builder.toString());
|
||||||
|
|
||||||
|
// 如果你不想解码%2B,则charset传null表示不做解码,编码时候也被忽略
|
||||||
|
builder = UrlBuilder.ofHttp("https://hutool.cn/a=%2B", null);
|
||||||
|
Assert.assertEquals("https://hutool.cn/a=%2B", builder.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user