提交 4f1bf708 编写于 作者: K kohsuke

improved the URL computation by using the current request URL.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@3775 71c3de6d-444a-0410-be80-ed276b4c234a
上级 ee25ce70
......@@ -2,6 +2,7 @@ package hudson.model;
import hudson.XmlFile;
import hudson.Util;
import hudson.Functions;
import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean;
......@@ -120,6 +121,17 @@ public abstract class AbstractItem extends Actionable implements Item {
}
public final String getUrl() {
// try to stick to the current view if possible
StaplerRequest req = Stapler.getCurrentRequest();
if (req != null) {
String seed = Functions.getNearestAncestorUrl(req,this);
if(seed!=null) {
// trim off the context path portion and leading '/', but add trailing '/'
return seed.substring(req.getServletContext().getContextPath().length()+1)+'/';
}
}
// otherwise compute the path normally
return getParent().getUrl()+getShortUrl();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册