提交 29cfe0c4 编写于 作者: K kohsuke

fixed issue #1135 by handling absolute URLs


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@7924 71c3de6d-444a-0410-be80-ed276b4c234a
上级 aef6109b
......@@ -776,4 +776,20 @@ public class Functions {
else
return base;
}
/**
* Computes the hyperlink to actions, to handle the situation when the {@link Action#getUrlName()}
* returns absolute URL.
*/
public static String getActionUrl(String itUrl,Action action) {
String urlName = action.getUrlName();
if(SCHEME.matcher(urlName).matches())
return urlName; // absolute URL
else
// relative URL name
return Stapler.getCurrentRequest().getContextPath()+'/'+itUrl+urlName;
}
private static final Pattern SCHEME = Pattern.compile("[a-z]+://.+");
}
......@@ -65,6 +65,10 @@ public interface Action extends Serializable, ModelObject {
* <p>
* This method should return a string that's unique among other {@link Action}s.
*
* <p>
* The returned string can be an absolute URL, like "http://www.sun.com/",
* which is useful for directly connecting to external systems.
*
* @return
* null if this action object doesn't need to be bound to web.
*/
......
......@@ -4,7 +4,8 @@
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<j:forEach var="action" items="${it.actions}">
<j:if test="${action.iconFileName!=null}">
<l:task icon="${h.getIconFilePath(action)}" href="${rootURL}/${it.url}${action.urlName}/" title="${action.displayName}" />
<l:task icon="${h.getIconFilePath(action)}" title="${action.displayName}"
href="${h.getActionUrl(it.url,action)}/" />
</j:if>
</j:forEach>
</j:jelly>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册