use of cn.hutool.core.net.url.UrlBuilder in project hutool by looly.
the class UrlBuilderTest method slashEncodeTest.
@Test
public void slashEncodeTest() {
// https://github.com/dromara/hutool/issues/1904
// 在query中,"/"是不可转义字符
// 见:https://www.rfc-editor.org/rfc/rfc3986.html#section-3.4
String url = "https://invoice.maycur.com/2b27a802-8423-4d41-86f5-63a6b259f61e.xlsx?download/2b27a802-8423-4d41-86f5-63a6b259f61e.xlsx&e=1630491088";
final UrlBuilder urlBuilder = UrlBuilder.ofHttp(url);
Assert.assertEquals(url, urlBuilder.toString());
}
use of cn.hutool.core.net.url.UrlBuilder in project hutool by looly.
the class UrlBuilderTest method paramTest.
@Test
public void paramTest() {
String url = "http://ci.xiaohongshu.com/spectrum/c136c98aa2047babe25b994a26ffa7b492bd8058?imageMogr2/thumbnail/x800/format/jpg";
final UrlBuilder builder = UrlBuilder.ofHttp(url);
Assert.assertEquals(url, builder.toString());
}
use of cn.hutool.core.net.url.UrlBuilder in project hutool by looly.
the class UrlBuilderTest method ofTest.
@Test
public void ofTest() {
final UrlBuilder builder = UrlBuilder.of("http://www.hutool.cn/aaa/bbb/?a=1&b=2#frag1", CharsetUtil.CHARSET_UTF_8);
Assert.assertEquals("http", builder.getScheme());
Assert.assertEquals("www.hutool.cn", builder.getHost());
Assert.assertEquals("aaa", builder.getPath().getSegment(0));
Assert.assertEquals("bbb", builder.getPath().getSegment(1));
Assert.assertEquals("1", builder.getQuery().get("a"));
Assert.assertEquals("2", builder.getQuery().get("b"));
Assert.assertEquals("frag1", builder.getFragment());
}
use of cn.hutool.core.net.url.UrlBuilder in project hutool by looly.
the class UrlQueryTest method ofHttpWithoutEncodeTest.
@Test
public void ofHttpWithoutEncodeTest() {
// charset为null表示不做编码
String url = "https://img-cloud.voc.com.cn/140/2020/09/03/c3d41b93e0d32138574af8e8b50928b376ca5ba61599127028157.png?imageMogr2/auto-orient/thumbnail/500&pid=259848";
final UrlBuilder urlBuilder = UrlBuilder.ofHttpWithoutEncode(url);
final String queryStr = urlBuilder.getQueryStr();
Assert.assertEquals("imageMogr2/auto-orient/thumbnail/500&pid=259848", queryStr);
}
use of cn.hutool.core.net.url.UrlBuilder in project hutool by looly.
the class HttpRequestTest method urlWithParamIfGetTest.
@Test
@Ignore
public void urlWithParamIfGetTest() {
UrlBuilder urlBuilder = new UrlBuilder();
urlBuilder.setScheme("https").setHost("hutool.cn");
HttpRequest httpRequest = new HttpRequest(urlBuilder);
httpRequest.setMethod(Method.GET).execute();
}
Aggregations