mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
Merge branch 'v5-dev' of github.com:looly/hutool into v5-dev
This commit is contained in:
commit
89300c5f4d
@ -3194,7 +3194,7 @@ public class FileUtil extends PathUtil {
|
||||
public static boolean isSub(File parent, File sub) {
|
||||
Assert.notNull(parent);
|
||||
Assert.notNull(sub);
|
||||
return sub.toPath().startsWith(parent.toPath());
|
||||
return sub.toPath().toAbsolutePath().normalize().startsWith(parent.toPath().toAbsolutePath().normalize());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -384,4 +384,11 @@ public class FileUtilTest {
|
||||
File file2 = new File("d:/test2/aaa");
|
||||
Assert.assertFalse(FileUtil.isSub(file, file2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSubRelativeTest() {
|
||||
File file = new File("..");
|
||||
File file2 = new File(".");
|
||||
Assert.assertTrue(FileUtil.isSub(file, file2));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user