Repository: commons-io
Updated Branches:
  refs/heads/master fcc636194 -> 703228a3d


[IO-483] FilenameUtils.getPrefixLength now works correctly for unix 
files/folder that are in the root folder and start with colons


Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/a7bd5682
Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/a7bd5682
Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/a7bd5682

Branch: refs/heads/master
Commit: a7bd568249f9ec20b69b2a700da6a0648e93a842
Parents: 9e2b2c0
Author: Marko Vasic <marko.z.va...@gmail.com>
Authored: Sat Sep 24 14:32:50 2016 -0500
Committer: Marko Vasic <marko.z.va...@gmail.com>
Committed: Sat Sep 24 14:32:50 2016 -0500

----------------------------------------------------------------------
 src/main/java/org/apache/commons/io/FilenameUtils.java         | 2 ++
 src/test/java/org/apache/commons/io/FilenameUtilsTestCase.java | 4 ++++
 2 files changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-io/blob/a7bd5682/src/main/java/org/apache/commons/io/FilenameUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/io/FilenameUtils.java 
b/src/main/java/org/apache/commons/io/FilenameUtils.java
index 3b1ef89..b9b9c18 100644
--- a/src/main/java/org/apache/commons/io/FilenameUtils.java
+++ b/src/main/java/org/apache/commons/io/FilenameUtils.java
@@ -667,6 +667,8 @@ public class FilenameUtils {
                         return 2;
                     }
                     return 3;
+                } else if (ch0 == UNIX_SEPARATOR) {
+                    return 1;
                 }
                 return NOT_FOUND;
 

http://git-wip-us.apache.org/repos/asf/commons-io/blob/a7bd5682/src/test/java/org/apache/commons/io/FilenameUtilsTestCase.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/io/FilenameUtilsTestCase.java 
b/src/test/java/org/apache/commons/io/FilenameUtilsTestCase.java
index fc6a025..bd97a5a 100644
--- a/src/test/java/org/apache/commons/io/FilenameUtilsTestCase.java
+++ b/src/test/java/org/apache/commons/io/FilenameUtilsTestCase.java
@@ -583,6 +583,10 @@ public class FilenameUtilsTestCase extends 
FileBasedTestCase {
         assertEquals(9, FilenameUtils.getPrefixLength("//server/a/b/c.txt"));
         assertEquals(-1, FilenameUtils.getPrefixLength("\\\\\\a\\b\\c.txt"));
         assertEquals(-1, FilenameUtils.getPrefixLength("///a/b/c.txt"));
+
+        assertEquals(1, FilenameUtils.getPrefixLength("/:foo"));
+        assertEquals(1, FilenameUtils.getPrefixLength("/:/"));
+        assertEquals(1, FilenameUtils.getPrefixLength("/:::::::.txt"));
     }
 
     @Test

Reply via email to