mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
local history: index out of bounds fixed
This commit is contained in:
@@ -44,7 +44,6 @@ public class Paths {
|
||||
}
|
||||
|
||||
public static String appended(String path, String child) {
|
||||
if (path.length() == 0) return child;
|
||||
path = appendParent(path);
|
||||
return path + child;
|
||||
}
|
||||
@@ -82,6 +81,7 @@ public class Paths {
|
||||
}
|
||||
|
||||
private static String appendParent(String parent) {
|
||||
if (parent.isEmpty()) return parent;
|
||||
if (parent.charAt(parent.length() - 1) != DELIM) parent += DELIM;
|
||||
return parent;
|
||||
}
|
||||
|
||||
@@ -42,6 +42,8 @@ public class PathsTest extends LocalHistoryTestCase {
|
||||
assertEquals("c:/root/file", Paths.appended("c:/root", "file"));
|
||||
assertEquals("/foo", Paths.appended("/", "foo"));
|
||||
assertEquals("/foo/bar", Paths.appended("/foo", "bar"));
|
||||
|
||||
assertEquals("bar", Paths.appended("", "bar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -79,6 +81,8 @@ public class PathsTest extends LocalHistoryTestCase {
|
||||
assertFalse(Paths.isParent("foo/bar", "foo/baz"));
|
||||
assertFalse(Paths.isParent("foo/bar", "foo/barr"));
|
||||
assertFalse(Paths.isParent("foo/bar", "foo/barr/baz"));
|
||||
|
||||
assertTrue(Paths.isParent("", "foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user