修复使用http文件流下载时文件名编码异常Gitee-#I4W0TQ

This commit is contained in:
陈精华
2022-03-10 09:47:05 +08:00
parent 051ad0f4ea
commit ba7b6eed4a
2 changed files with 21 additions and 1 deletions

View File

@ -21,4 +21,12 @@ public class WebUtilsTests {
String out = "https://file.keking.cn/demo/%23hello%26world.txt?param0=0&param1=1";
assert WebUtils.encodeUrlFileName(in).equals(out);
}
@Test
void encodeUrlFullFileNameTestWithParams() {
// 测试对URL中使用fullfilename参数的文件名部分进行UTF-8编码
String in = "https://file.keking.cn/demo/download?param0=0&fullfilename=hello#0.txt";
String out = "https://file.keking.cn/demo/download?param0=0&fullfilename=hello%230.txt";
assert WebUtils.encodeUrlFileName(in).equals(out);
}
}