[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
This commit is contained in:
mindless committed 2009-11-01 00:00:32 +00:00
1 parent 6277adff9a
commit bc9db0fd0a
1 file changed
+6 -4
+6 -4
View File
@@ -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 <T> List<T> singletonList(T t) {