提交 bc9db0fd 编写于 作者: M mindless

[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
上级 6277adff
......@@ -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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册