Skip to content

Commit

Permalink
[JENKINS-21500] Link to workspace root directory is not accessible in…
Browse files Browse the repository at this point in the history
… 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 d4cdb66
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
Expand Up @@ -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 '/'
Expand All @@ -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
Expand Down
Expand Up @@ -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("",
Expand All @@ -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
Expand Down

0 comments on commit d4cdb66

Please sign in to comment.