mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix url path bug
This commit is contained in:
parent
68d5cf35d4
commit
e8d15ec29c
@ -18,6 +18,7 @@
|
||||
### Bug修复
|
||||
* 【core 】 修复FileTypeUtil中OFD格式判断问题(pr#1489@Github)
|
||||
* 【core 】 修复CamelCaseLinkedMap和CaseInsensitiveLinkedMap的Linked失效问题(pr#1490@Github)
|
||||
* 【core 】 修复UrlPath中=被转义的问题
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -128,7 +128,7 @@ public class UrlPath {
|
||||
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
for (String segment : segments) {
|
||||
builder.append(CharUtil.SLASH).append(URLUtil.encodeAll(segment, charset));
|
||||
builder.append(CharUtil.SLASH).append(URLUtil.encodeQuery(segment, charset));
|
||||
}
|
||||
if (withEngTag || StrUtil.isEmpty(builder)) {
|
||||
builder.append(CharUtil.SLASH);
|
||||
|
@ -235,4 +235,12 @@ public class UrlBuilderTest {
|
||||
final UrlBuilder urlBuilder = UrlBuilder.of(webUrl, StandardCharsets.UTF_8);
|
||||
Assert.assertEquals("a=123&b=4%3F6&c=789", urlBuilder.getQueryStr());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void encodePathTest(){
|
||||
// Path中的某些符号无需转义,比如=
|
||||
final String urlStr = "http://hq.sinajs.cn/list=sh600519";
|
||||
final UrlBuilder urlBuilder = UrlBuilder.ofHttp(urlStr, CharsetUtil.CHARSET_UTF_8);
|
||||
Assert.assertEquals(urlStr, urlBuilder.toString());
|
||||
}
|
||||
}
|
||||
|
@ -318,4 +318,11 @@ public class HttpUtilTest {
|
||||
final String s = HttpUtil.get(url);
|
||||
Console.log(s);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void sinajsTest(){
|
||||
final String s = HttpUtil.get("http://hq.sinajs.cn/list=sh600519");
|
||||
Console.log(s);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user