提交 00bfa356 编写于 作者: K Kohsuke Kawaguchi

Added a convenience method.

This change is originally from pull request #682.
上级 902edc38
......@@ -513,6 +513,25 @@ public class Util {
else return s;
}
/**
* Ensure string ends with suffix
*
* @param subject Examined string
* @param suffix Desired suffix
* @return Original subject in case it already ends with suffix, null in
* case subject was null and subject + suffix otherwise.
* @since 1.505
*/
public static String ensureEndsWith(String subject, String suffix) {
if (subject == null) return null;
if (subject.endsWith(suffix)) return subject;
return subject + suffix;
}
/**
* Computes MD5 digest of the given input stream.
*
......
......@@ -1868,8 +1868,7 @@ public class Jenkins extends AbstractCIBase implements ModifiableTopLevelItemGro
public String getRootUrl() {
String url = JenkinsLocationConfiguration.get().getUrl();
if(url!=null) {
if (!url.endsWith("/")) url += '/';
return url;
return Util.ensureEndsWith(url,"/");
}
StaplerRequest req = Stapler.getCurrentRequest();
if(req!=null)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册