Commit 263b4918 authored by Marco Descher's avatar Marco Descher
Browse files

[23046] IVirtualFilesystemService handling of directories with spaces

parent b07a660b
Pipeline #22150 passed with stages
in 4 minutes and 38 seconds
......@@ -264,6 +264,8 @@ public interface IVirtualFilesystemService {
*/
public static URI stringToURI(String value) throws URISyntaxException, MalformedURLException{
value = value.replaceAll("%20", " ");
// C:\main.c++ -> file:/C:/main.c++
if (value.length() > 2 && value.charAt(1) == ':') {
String replaced = value.replace("\\", "/");
......
......@@ -56,4 +56,22 @@ public class VirtualFilesystemServiceTest {
assertEquals("C:/Windows/Test", hidePasswordInUrlString);
}
@Test
public void parseHandlingWithSpaces() throws IOException {
IVirtualFilesystemHandle dirWithSpace = service.of("C:\\Users\\mad\\Documents\\Arbeit\\Testing\\Omnivore\\Abstand mit\\");
URL url = dirWithSpace.toURL();
assertEquals(new URL("file://C:/Users/mad/Documents/Arbeit/Testing/Omnivore/Abstand%20mit/"), url);
IVirtualFilesystemHandle dirWithSpaceSubdir = dirWithSpace.subDir("1");
url = dirWithSpaceSubdir.toURL();
assertEquals(new URL("file://C:/Users/mad/Documents/Arbeit/Testing/Omnivore/Abstand%20mit/1/"), url);
// multiple spaces
dirWithSpace = service.of("C:\\Users\\mad\\Documents\\Arbeit\\Testing\\Omni vore\\Abstand mit\\");
url = dirWithSpace.toURL();
assertEquals(new URL("file://C:/Users/mad/Documents/Arbeit/Testing/Omni%20%20vore/Abstand%20mit/"), url);
dirWithSpaceSubdir = dirWithSpace.subDir("1");
url = dirWithSpaceSubdir.toURL();
assertEquals(new URL("file://C:/Users/mad/Documents/Arbeit/Testing/Omni%20%20vore/Abstand%20mit/1/"), url);
}
}
Supports Markdown
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