Skip to content

Commit

Permalink
Issue #10084 - Fixing comments
Browse files Browse the repository at this point in the history
  • Loading branch information
joakime committed Jul 10, 2023
1 parent 4927b1d commit 8172a46
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static String getFileName(URI uri)
*/
public static String getFileName(String path)
{
if (path == null || path.equals("/"))
if (path == null || "/".equals(path))
return "";
int idx = path.lastIndexOf('/');
if (idx >= 0)
Expand All @@ -79,19 +79,19 @@ public static String getFileName(String path)
{
// we found the trailing slash
// eg: file:/path/to/dir/
// we want to return the "dir/" here
// we want to return the "dir" segment here
int previousSlash = path.lastIndexOf('/', idx - 1);
if (previousSlash >= 0)
{
// we have a previous slash
// so return the segment and trailing slash
// so return the segment without the trailing slash
return path.substring(previousSlash + 1, idx);
}
else
{
// we have no previous slash
// this input string is something like "foo/"
// so return it all
// so return the segment without trailing slash
return path.substring(0, idx);
}
}
Expand Down

0 comments on commit 8172a46

Please sign in to comment.