Fixed potential issue where menu can render duplicate slashes. CLK-733
git-svn-id: https://svn.apache.org/repos/asf/click/trunk/click@1040077 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/extras/src/org/apache/click/extras/control/Menu.java b/extras/src/org/apache/click/extras/control/Menu.java
index 7a769fb..9ebeb86 100644
--- a/extras/src/org/apache/click/extras/control/Menu.java
+++ b/extras/src/org/apache/click/extras/control/Menu.java
@@ -1027,7 +1027,14 @@
// Guard against rendering "null" in the href
localPath = "";
}
- return context.getResponse().encodeURL(context.getRequest().getContextPath() + "/" + localPath);
+ StringBuilder sb = new StringBuilder();
+ String contextPath = context.getRequest().getContextPath();
+ sb.append(contextPath);
+ if (localPath.length() > 0 && localPath.charAt(0) != '/') {
+ sb.append('/');
+ }
+ sb.append(localPath);
+ return context.getResponse().encodeURL(sb.toString());
}
}