提交 ae710c81 编写于 作者: K kohsuke

[FIXED HUDSON-2748]

    If a view name or job name contains whitespace, the navigation bar doesn't show the current positions correctly.
    (<a href="http://hudson.dev.java.net/issues/show_bug.cgi?id=2748">issue 2748</a>)

In 1.267.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@13815 71c3de6d-444a-0410-be80-ed276b4c234a
上级 8b3dd1e0
......@@ -54,6 +54,7 @@ import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.lang.management.LockInfo;
import java.lang.management.ManagementFactory;
import java.lang.management.MonitorInfo;
......@@ -63,6 +64,7 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.MalformedURLException;
import java.net.URLDecoder;
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
......@@ -976,6 +978,20 @@ public class Functions {
return Hudson.getInstance().getUpdateCenter().getUrl();
}
/**
* If the given href link is matching the current page, return true.
*
* Used in <tt>task.jelly</tt> to decide if the page should be highlighted.
*/
public boolean hyperlinkMatchesCurrentPage(String href) throws UnsupportedEncodingException {
String url = Stapler.getCurrentRequest().getRequestURL().toString();
url = URLDecoder.decode(url,"UTF-8");
href = URLDecoder.decode(href,"UTF-8");
return (href.length()>1 && url.endsWith(href))
|| (href.equals(".") && url.endsWith("."));
}
/**
* Gets all the {@link PageDecorator}s.
*/
......
......@@ -13,11 +13,7 @@
The semantics is that when one of the nested <task> matches, the parent is also considered as a match
and thus gets a highlight.
-->
<j:invokeStatic var="requestURL" className="java.net.URLDecoder" method="decode">
<j:arg value="${request.requestURL.toString()}"/>
<j:arg value="UTF-8"/>
</j:invokeStatic>
<j:set var="match" value="${(size(href) gt 1 and requestURL.endsWith(href)) or (href=='.' and requestURL.endsWith('/'))}" />
<j:set var="match" value="${h.hyperlinkMatchesCurrentPage(href)}" />
<j:scope>
<j:set var="taskMatching" value="${context.parent}"/>
<d:invokeBody />
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册