diff --git a/core/src/main/java/hudson/Functions.java b/core/src/main/java/hudson/Functions.java index a5bbc68493..3b2eb18310 100644 --- a/core/src/main/java/hudson/Functions.java +++ b/core/src/main/java/hudson/Functions.java @@ -1002,10 +1002,10 @@ public class Functions { if(SCHEME.matcher(urlName).matches()) return urlName; // absolute URL if(urlName.startsWith("/")) - return Stapler.getCurrentRequest().getContextPath()+urlName+'/'; + return Stapler.getCurrentRequest().getContextPath()+urlName; else // relative URL name - return Stapler.getCurrentRequest().getContextPath()+'/'+itUrl+urlName+'/'; + return Stapler.getCurrentRequest().getContextPath()+'/'+itUrl+urlName; } /** @@ -1074,11 +1074,13 @@ public class Functions { */ public boolean hyperlinkMatchesCurrentPage(String href) throws UnsupportedEncodingException { String url = Stapler.getCurrentRequest().getRequestURL().toString(); + if (href.length() <= 1) return href.equals(".") && url.endsWith("/"); url = URLDecoder.decode(url,"UTF-8"); href = URLDecoder.decode(href,"UTF-8"); + if (url.endsWith("/")) url = url.substring(0, url.length() - 1); + if (href.endsWith("/")) href = href.substring(0, href.length() - 1); - return (href.length()>1 && url.endsWith(href)) - || (href.equals(".") && url.endsWith(".")); + return url.endsWith(href)); } public List singletonList(T t) {