Commit cffbc8dd authored by Geoffrey Métais's avatar Geoffrey Métais

Get name from folder path with trailing '/'

parent c4ace965
......@@ -70,7 +70,11 @@ public class FileUtils {
if (path == null)
return "";
int index = path.lastIndexOf('/');
if (index> -1)
if (index == path.length()-1) {
path = path.substring(0, index);
index = path.lastIndexOf('/');
}
if (index > -1)
return path.substring(index+1);
else
return path;
......
......@@ -12,6 +12,8 @@ public class StringsTest {
assertEquals("", FileUtils.getFileNameFromPath(null));
assertEquals("", FileUtils.getFileNameFromPath("/"));
assertEquals("file.txt", FileUtils.getFileNameFromPath(path));
path = "/home/folder/subfolder/";
assertEquals("subfolder", FileUtils.getFileNameFromPath(path));
}
//TextUtils mock is not ready :/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment