mirror of
https://gitee.com/dromara/hutool.git
synced 2025-05-02 20:02:49 +08:00
fix url bug
This commit is contained in:
parent
70c0f4cacc
commit
a4c8ebc572
@ -101,6 +101,11 @@ public class UrlPath {
|
||||
if (StrUtil.isNotEmpty(path)) {
|
||||
path = path.trim();
|
||||
|
||||
// 原URL中以/结尾,则这个规则需保留,issue#I1G44J@Gitee
|
||||
if(StrUtil.endWith(path, CharUtil.SLASH)){
|
||||
this.withEngTag = true;
|
||||
}
|
||||
|
||||
final StringTokenizer tokenizer = new StringTokenizer(path, "/");
|
||||
while (tokenizer.hasMoreTokens()) {
|
||||
add(URLUtil.decode(tokenizer.nextToken(), charset));
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.hutool.core.net;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.net.url.UrlBuilder;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import org.junit.Assert;
|
||||
@ -188,4 +189,13 @@ public class UrlBuilderTest {
|
||||
"&chksm=6cbda3a25bca2ab4516410db6ce6e125badaac2f8c5548ea6e18eab6dc3c5422cb8cbe1095f7",
|
||||
builder.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void endWithSlashTest(){
|
||||
// 原URL中以/结尾,则这个规则需保留,issue#I1G44J@Gitee
|
||||
final String today = DateUtil.date().toString("yyyyMMdd");
|
||||
final String getWorkDayUrl = "https://tool.bitefu.net/jiari/?info=1&d=" + today;
|
||||
final UrlBuilder builder = UrlBuilder.ofHttp(getWorkDayUrl, CharsetUtil.CHARSET_UTF_8);
|
||||
Assert.assertEquals(getWorkDayUrl, builder.toString());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user