mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
change extName
This commit is contained in:
@@ -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;
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user