diff --git a/source/net/filebot/util/FileUtilities.java b/source/net/filebot/util/FileUtilities.java index d41a5ada..5f94985d 100644 --- a/source/net/filebot/util/FileUtilities.java +++ b/source/net/filebot/util/FileUtilities.java @@ -629,10 +629,11 @@ public final class FileUtilities { } public static String normalizePathSeparators(String path) { - // special handling for UNC paths + // special handling for UNC paths (e.g. \\server\share\path) if (path.startsWith(UNC_PREFIX)) { - return UNC_PREFIX + replacePathSeparators(path.substring(UNC_PREFIX.length()), "/"); + return UNC_PREFIX + normalizePathSeparators(path.substring(UNC_PREFIX.length())); } + return replacePathSeparators(path, "/"); } diff --git a/test/net/filebot/util/FileUtilitiesTest.java b/test/net/filebot/util/FileUtilitiesTest.java index 9fc7185a..58fd7948 100644 --- a/test/net/filebot/util/FileUtilitiesTest.java +++ b/test/net/filebot/util/FileUtilitiesTest.java @@ -48,4 +48,14 @@ public class FileUtilitiesTest { assertFalse(FileUtilities.isDerived(new File("10.z"), new File("1.mp4"))); } + @Test + public void normalizePathSeparators() { + assertEquals("C:/file.txt", FileUtilities.normalizePathSeparators("C:\\file.txt")); + assertEquals("/Volume/USB/file.txt", FileUtilities.normalizePathSeparators("/Volume\\USB/file.txt")); + + assertEquals("\\\\server/share/data/file.txt", FileUtilities.normalizePathSeparators("\\\\server\\share\\data\\file.txt")); + assertEquals("\\\\server/share/data/file.txt", FileUtilities.normalizePathSeparators("\\\\server\\share\\data\\file.txt")); + assertEquals("/server/share/data/file.txt", FileUtilities.normalizePathSeparators("//server/share/data/file.txt")); + } + }