change extName

This commit is contained in:
Looly 2022-03-04 00:09:56 +08:00
parent ccc9f2568f
commit ae8849c665
3 changed files with 17 additions and 7 deletions

View File

@ -2,20 +2,21 @@
# 🚀Changelog
-------------------------------------------------------------------------------------------------------------
# 5.7.23 (2022-03-03)
# 5.7.23 (2022-03-04)
### 🐣新特性
* 【http 】 HttpRequest.form采用TableMap方式issue#I4W427@gitee
* 【core 】 AnnotationUtil增加getAnnotationAlias方法pr#554@gitee
* 【http 】 HttpRequest.form采用TableMap方式issue#I4W427@Gitee
* 【core 】 AnnotationUtil增加getAnnotationAlias方法pr#554@Gitee
* 【core 】 FileUtil.extName增加对tar.gz特殊处理issue#I4W5FS@Gitee
### 🐞Bug修复
* 【core 】 修复ObjectUtil.hasNull传入null返回true的问题pr#555@gitee
* 【core 】 修复ObjectUtil.hasNull传入null返回true的问题pr#555@Gitee
-------------------------------------------------------------------------------------------------------------
# 5.7.22 (2022-03-01)
### 🐣新特性
* 【poi 】 ExcelUtil.readBySax增加对POI-5.2.0的兼容性issue#I4TJF4@gitee
* 【extra 】 Ftp增加构造issue#I4TKXP@gitee
* 【poi 】 ExcelUtil.readBySax增加对POI-5.2.0的兼容性issue#I4TJF4@Gitee
* 【extra 】 Ftp增加构造issue#I4TKXP@Gitee
* 【core 】 GenericBuilder支持Map构建pr#540@Github
* 【json 】 新增TemporalAccessorSerializer
* 【core 】 使多个xxxBuilder实现Builder接口扩展CheckedUtilpr#545@Gitee
@ -547,7 +548,7 @@
* 【json 】 增加JSONWriter
* 【core 】 IdUtil增加getWorkerId和getDataCenterIdissueI3Y5NI@Gitee
* 【core 】 JWTValidator增加leeway重载
* 【core 】 增加RegexPoolissue#I3W9ZF@gitee
* 【core 】 增加RegexPoolissue#I3W9ZF@Gitee
### 🐞Bug修复
* 【json 】 修复XML转义字符的问题issue#I3XH09@Gitee

View File

@ -222,6 +222,11 @@ public class FileNameUtil {
if (index == -1) {
return StrUtil.EMPTY;
} else {
// issue#I4W5FS@Gitee
if(fileName.endsWith("tar.gz")){
return "tar.gz";
}
String ext = fileName.substring(index + 1);
// 扩展名中不能包含路径相关的符号
return StrUtil.containsAny(ext, UNIX_SEPARATOR, WINDOWS_SEPARATOR) ? StrUtil.EMPTY : ext;

View File

@ -392,6 +392,10 @@ public class FileUtilTest {
path = FileUtil.isWindows() ? "d:\\aaa\\bbb\\cc\\fff.xlsx" : "~/Desktop/hutool/fff.xlsx";
mainName = FileUtil.extName(path);
Assert.assertEquals("xlsx", mainName);
path = FileUtil.isWindows() ? "d:\\aaa\\bbb\\cc\\fff.tar.gz" : "~/Desktop/hutool/fff.tar.gz";
mainName = FileUtil.extName(path);
Assert.assertEquals("tar.gz", mainName);
}
@Test