Skip to content

Commit

Permalink
Fix for create root file instance
Browse files Browse the repository at this point in the history
  • Loading branch information
berisd committed Oct 28, 2016
1 parent 6f59db6 commit 904d010
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/main/java/at/beris/virtualfile/UrlFileContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ public VirtualFile newFile(URL url) {
VirtualFile file = null;
StringBuilder stringBuilder = new StringBuilder();

for (String pathPart : fullPath.split("/")) {
String[] pathParts = "/".equals(fullPath) ? new String[]{"/"} : fullPath.split("/");
for (String pathPart : pathParts) {
stringBuilder.append(pathPart);
if (stringBuilder.length() < fullPath.length())
stringBuilder.append('/');
Expand Down
7 changes: 6 additions & 1 deletion src/test/java/at/beris/virtualfile/UrlFileContextTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

package at.beris.virtualfile;

import at.beris.virtualfile.cache.FileCache;
import at.beris.virtualfile.config.Configurator;
import org.junit.Assert;
import org.junit.Before;
Expand Down Expand Up @@ -39,4 +38,10 @@ public void getParentFile() throws MalformedURLException {
VirtualFile parentFile3 = fileContext.newFile(new URL("file:/this/"));
Assert.assertNotSame(parentFile1, parentFile3);
}

@Test
public void newRootFile() throws MalformedURLException {
VirtualFile virtualFile = fileContext.newFile(new URL("file:/"));
Assert.assertNotNull(virtualFile);
}
}

0 comments on commit 904d010

Please sign in to comment.