Skip to content

Commit

Permalink
added condition to handle views
Browse files Browse the repository at this point in the history
  • Loading branch information
Hui Jun Ng committed Sep 13, 2019
1 parent 0114296 commit f0b36fa
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.jenkinsci.plugins.ParameterizedRemoteTrigger;

import static java.lang.Math.min;
import static org.apache.commons.lang.StringUtils.isEmpty;
import static org.apache.commons.lang.StringUtils.trimToEmpty;
import static org.apache.commons.lang.StringUtils.trimToNull;
Expand Down Expand Up @@ -510,7 +511,12 @@ private String getRootUrlFromJobUrl(String jobUrl) throws MalformedURLException
if (isEmpty(jobUrl))
return null;
if (FormValidationUtils.isURL(jobUrl)) {
int index = jobUrl.indexOf("/job/");
int index;
if (jobUrl.contains("/view/")) {
index = min(jobUrl.indexOf("/view/"), jobUrl.indexOf("/job/"));
} else {
index = jobUrl.indexOf("/job/");
}
if (index < 0)
throw new MalformedURLException("Expected '/job/' element in job URL but was: " + jobUrl);
return jobUrl.substring(0, index);
Expand Down

0 comments on commit f0b36fa

Please sign in to comment.