diff --git a/CHANGELOG.md b/CHANGELOG.md index 2cf4af00a..fcd3d51bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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接口,扩展CheckedUtil(pr#545@Gitee) @@ -547,7 +548,7 @@ * 【json 】 增加JSONWriter * 【core 】 IdUtil增加getWorkerId和getDataCenterId(issueI3Y5NI@Gitee) * 【core 】 JWTValidator增加leeway重载 -* 【core 】 增加RegexPool(issue#I3W9ZF@gitee) +* 【core 】 增加RegexPool(issue#I3W9ZF@Gitee) ### 🐞Bug修复 * 【json 】 修复XML转义字符的问题(issue#I3XH09@Gitee) diff --git a/hutool-core/src/main/java/cn/hutool/core/io/file/FileNameUtil.java b/hutool-core/src/main/java/cn/hutool/core/io/file/FileNameUtil.java index 6dca23e7d..07436e151 100644 --- a/hutool-core/src/main/java/cn/hutool/core/io/file/FileNameUtil.java +++ b/hutool-core/src/main/java/cn/hutool/core/io/file/FileNameUtil.java @@ -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; diff --git a/hutool-core/src/test/java/cn/hutool/core/io/FileUtilTest.java b/hutool-core/src/test/java/cn/hutool/core/io/FileUtilTest.java index d70490e8b..4e72c827f 100644 --- a/hutool-core/src/test/java/cn/hutool/core/io/FileUtilTest.java +++ b/hutool-core/src/test/java/cn/hutool/core/io/FileUtilTest.java @@ -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