From a24f7921dd3c2e2ecd55ef61fed1001b90fa24c9 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Mon, 13 Aug 2007 01:41:19 +0000 Subject: [PATCH] simplified. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@4250 71c3de6d-444a-0410-be80-ed276b4c234a --- .../java/hudson/model/DirectoryBrowserSupport.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/hudson/model/DirectoryBrowserSupport.java b/core/src/main/java/hudson/model/DirectoryBrowserSupport.java index 36d10f4ee9..96ba7da0a5 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