mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix ext name bug
This commit is contained in:
parent
cd73435161
commit
ee3022b4b3
@ -179,6 +179,14 @@ public class FileNameUtil {
|
||||
if (0 == len) {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
//issue#2642,多级扩展名的主文件名
|
||||
for (final CharSequence specialSuffix : SPECIAL_SUFFIX) {
|
||||
if(StrUtil.endWith(fileName, "." + specialSuffix)){
|
||||
return StrUtil.subPre(fileName, len - specialSuffix.length() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (CharUtil.isFileSeparator(fileName.charAt(len - 1))) {
|
||||
len--;
|
||||
}
|
||||
|
@ -12,4 +12,10 @@ public class FileNameUtilTest {
|
||||
name = FileNameUtil.cleanInvalid("\r1\r\n2\n");
|
||||
Assert.assertEquals("12", name);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mainNameTest() {
|
||||
final String s = FileNameUtil.mainName("abc.tar.gz");
|
||||
Assert.assertEquals("abc", s);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user