Skip to content
Permalink
Browse files
[JENKINS-21500] Link to workspace root directory is not accessible in…
… results

- The link to the workspace root is not displayed because the text of the link is an empty string.
- All links to directories were extended by trailing slash '/' character.
  • Loading branch information
mixalturek committed Jan 24, 2014
1 parent e55f588 commit d4cdb66d378c681bd8c570c4282c13ebb0c91424
Showing 2 changed files with 17 additions and 13 deletions.
@@ -67,11 +67,12 @@ public void add(String filePath, String languageName, int lineCount){
* Examples of input and output:
* (empty string) - (empty string)
* file.java - (empty string)
* /test/file.java - /test
* /cygdrive/c/test/file.java - /cygdrive/c/test
* c:/test/file.java - c:/test
* /test/ - /test
* /test - (empty string) ... is it file or directory?
* / - /
* /test/file.java - /test/
* /cygdrive/c/test/file.java - /cygdrive/c/test/
* c:/test/file.java - c:/test/
* /test/ - /test/
* /test - / ... is it file or directory?
*
* @param filePath
* the path containing folders and file name, Unix separators '/'
@@ -83,7 +84,8 @@ public static String extractFolder(String filePath){
int index = filePath.lastIndexOf(DIRECTORY_SEPARATOR);

if(index != -1) {
return filePath.substring(0, index);
// +1 means include also the ending slash '/'
return filePath.substring(0, index + 1);
}

// No separator found, probably only a file name
@@ -11,13 +11,13 @@
public class SloccountReportTest {
@Test
public void testExtractFolder() {
Assert.assertEquals("/test",
Assert.assertEquals("/test/",
SloccountReport.extractFolder("/test/file.java"));

Assert.assertEquals("/cygdrive/c/test",
Assert.assertEquals("/cygdrive/c/test/",
SloccountReport.extractFolder("/cygdrive/c/test/file.java"));

Assert.assertEquals("c:/test",
Assert.assertEquals("c:/test/",
SloccountReport.extractFolder("c:/test/file.java"));

Assert.assertEquals("",
@@ -26,16 +26,18 @@ public void testExtractFolder() {
Assert.assertEquals("",
SloccountReport.extractFolder(""));

Assert.assertEquals("test",
Assert.assertEquals("test/",
SloccountReport.extractFolder("test/file.java"));

// It searches the separator from right
Assert.assertEquals("/test",
Assert.assertEquals("/test/",
SloccountReport.extractFolder("/test/"));

// It searches the separator from right
Assert.assertEquals("",
Assert.assertEquals("/",
SloccountReport.extractFolder("/test"));

Assert.assertEquals("/",
SloccountReport.extractFolder("/"));
}

@Test

0 comments on commit d4cdb66

Please sign in to comment.