From bc9db0fd0a71f03484a9612149b5a4de2ff28cce Mon Sep 17 00:00:00 2001 From: mindless Date: Sun, 1 Nov 2009 00:00:32 +0000 Subject: [PATCH] [FIXED HUDSON-4720] Don't always append / to non-absolute action URLs, as this may break some links (.../*.html for example). See related HUDSON-1335, HUDSON-1679, r347 and r11319. Updated hyperlinkMatchesCurrentPage to ignore trailing / in matching to avoid regression in bold context links. Also fixed tiny bug introduced in r13815 where "/" was changed to "." in moving code from jelly to Functions, causing a couple links in LogRecorder area (with href=".") to not show as bold. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@23393 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/main/java/hudson/Functions.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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) {