diff --git a/core/src/main/java/hudson/model/DirectoryBrowserSupport.java b/core/src/main/java/hudson/model/DirectoryBrowserSupport.java index 36d10f4ee920e1aff701582824c077106728d824..96ba7da0a536630d0c3618e6a67c3fa70e2fe37b 100644 --- a/core/src/main/java/hudson/model/DirectoryBrowserSupport.java +++ b/core/src/main/java/hudson/model/DirectoryBrowserSupport.java @@ -153,8 +153,7 @@ public final class DirectoryBrowserSupport { req.setAttribute("it",this); List parentPaths = buildParentPath(path); req.setAttribute("parentPath",parentPaths); - req.setAttribute("topPath", - parentPaths.isEmpty() ? "." : repeat("../",parentPaths.size())); + req.setAttribute("topPath", createBackRef(parentPaths.size())); req.setAttribute("files",files); req.setAttribute("icon",icon); req.setAttribute("path",path); @@ -209,16 +208,17 @@ public final class DirectoryBrowserSupport { int current=1; while(tokens.hasMoreTokens()) { String token = tokens.nextToken(); - r.add(new Path(repeat("../",total-current),token,true,0)); + r.add(new Path(createBackRef(total - current),token,true,0)); current++; } return r; } - private static String repeat(String s,int times) { - StringBuffer buf = new StringBuffer(s.length()*times); + private static String createBackRef(int times) { + if(times==0) return "."; + StringBuffer buf = new StringBuffer(3*times); for(int i=0; i