Search in sources :

Example 6 with UrlBuilder

use of cn.hutool.core.net.url.UrlBuilder in project hutool by looly.

the class UrlBuilderTest method dotEncodeTest.

@Test
public void dotEncodeTest() {
    final UrlBuilder urlBuilder = UrlBuilder.ofHttp("http://xtbgyy.digitalgd.com.cn/ebus/../../..", CharsetUtil.CHARSET_UTF_8);
    Assert.assertEquals("http://xtbgyy.digitalgd.com.cn/ebus/../../..", urlBuilder.toString());
}
Also used : UrlBuilder(cn.hutool.core.net.url.UrlBuilder) Test(org.junit.Test)

Example 7 with UrlBuilder

use of cn.hutool.core.net.url.UrlBuilder in project hutool by looly.

the class UrlBuilderTest method multiSlashTest.

@Test
public void multiSlashTest() {
    // issue#I25MZL,某些URL中有多个斜杠,此为合法路径
    final UrlBuilder urlBuilder = UrlBuilder.ofHttp("https://hutool.cn//file/test.jpg", CharsetUtil.CHARSET_UTF_8);
    Assert.assertEquals("https://hutool.cn//file/test.jpg", urlBuilder.toString());
}
Also used : UrlBuilder(cn.hutool.core.net.url.UrlBuilder) Test(org.junit.Test)

Example 8 with UrlBuilder

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());
}
Also used : UrlBuilder(cn.hutool.core.net.url.UrlBuilder) Test(org.junit.Test)

Example 9 with UrlBuilder

use of cn.hutool.core.net.url.UrlBuilder in project hutool by looly.

the class UrlBuilderTest method testChineseFragmentWithPath.

@Test
public void testChineseFragmentWithPath() {
    String buildUrl = new UrlBuilder().setScheme("https").setHost("www.hutool.cn").addPath("/s").setFragment("测试").build();
    Assert.assertEquals("https://www.hutool.cn/s#%E6%B5%8B%E8%AF%95", buildUrl);
}
Also used : UrlBuilder(cn.hutool.core.net.url.UrlBuilder) Test(org.junit.Test)

Example 10 with UrlBuilder

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());
}
Also used : UrlBuilder(cn.hutool.core.net.url.UrlBuilder) Test(org.junit.Test)

Aggregations

UrlBuilder (cn.hutool.core.net.url.UrlBuilder)45 Test (org.junit.Test)44 URI (java.net.URI)2 AgentAuthorize (io.jpom.system.AgentAuthorize)1 Inet4Address (java.net.Inet4Address)1 InetAddress (java.net.InetAddress)1