mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix bug
This commit is contained in:
parent
d815af53de
commit
282d6245a4
@ -1,11 +1,13 @@
|
|||||||
package cn.hutool.core.net.url;
|
package cn.hutool.core.net.url;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.hutool.core.net.RFC3986;
|
import cn.hutool.core.net.RFC3986;
|
||||||
import cn.hutool.core.net.URLDecoder;
|
import cn.hutool.core.net.URLDecoder;
|
||||||
import cn.hutool.core.util.CharUtil;
|
import cn.hutool.core.util.CharUtil;
|
||||||
import cn.hutool.core.text.StrUtil;
|
import cn.hutool.core.text.StrUtil;
|
||||||
|
import cn.hutool.core.util.ObjUtil;
|
||||||
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
@ -55,12 +57,12 @@ public class UrlPath {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取path的节点列表
|
* 获取path的节点列表,如果列表为空,返回{@link ListUtil#empty()}
|
||||||
*
|
*
|
||||||
* @return 节点列表
|
* @return 节点列表
|
||||||
*/
|
*/
|
||||||
public List<String> getSegments() {
|
public List<String> getSegments() {
|
||||||
return this.segments;
|
return ObjUtil.defaultIfNull(this.segments, ListUtil.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -470,4 +470,13 @@ public class UrlBuilderTest {
|
|||||||
|
|
||||||
Assert.assertEquals("127.0.0.1:8080", builder.getAuthority());
|
Assert.assertEquals("127.0.0.1:8080", builder.getAuthority());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void addPathTest(){
|
||||||
|
//https://gitee.com/dromara/hutool/issues/I5O4ML
|
||||||
|
UrlBuilder.of().addPath("");
|
||||||
|
UrlBuilder.of().addPath("/");
|
||||||
|
UrlBuilder.of().addPath("//");
|
||||||
|
UrlBuilder.of().addPath("//a");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user