mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
改进UrlQuery
对无参URL增加判断识别(issue#IBRVE4@Gitee)
This commit is contained in:
parent
161cb6fc19
commit
8fa1481c73
@ -227,6 +227,9 @@ public class UrlQuery {
|
|||||||
if (StrUtil.isBlank(queryStr)) {
|
if (StrUtil.isBlank(queryStr)) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
} else if (StrUtil.startWith(queryStr, "http://") || StrUtil.startWith(queryStr, "https://")) {
|
||||||
|
// issue#IBRVE4 用户传入只有URL,没有param部分,返回空
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
package org.dromara.hutool.core.net;
|
||||||
|
|
||||||
|
import org.dromara.hutool.core.net.url.UrlQueryUtil;
|
||||||
|
import org.dromara.hutool.core.util.CharsetUtil;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
public class IssueIBRVE4Test {
|
||||||
|
@Test
|
||||||
|
public void decodeParamMapNoParamTest() {
|
||||||
|
// 参数值不存在分界标记等号时
|
||||||
|
// 无参数值时
|
||||||
|
final Map<String, String> paramMap = UrlQueryUtil.decodeQuery("https://hutool.cn/api.action", CharsetUtil.UTF_8);
|
||||||
|
assertEquals(0,paramMap.size());
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void decodeParamMapListNoParamTest() {
|
||||||
|
// 参数值不存在分界标记等号时
|
||||||
|
// 无参数值时
|
||||||
|
final Map<String, String> paramMap1 = UrlQueryUtil.decodeQuery("https://hutool.cn/api.action", CharsetUtil.UTF_8);
|
||||||
|
assertEquals(0,paramMap1.size());
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user