Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fetchTrendsData(theProps) {
const { pipeline } = theProps;
const baseUrl = `${AppConfig.getRestRoot()}/organizations/${AppConfig.getOrganizationName()}/pipelines/${pipeline.fullName}`;
let fullUrl;
if (capable(pipeline, MULTIBRANCH_PIPELINE)) {
const branchName = this._selectedBranch(theProps, pipeline);
fullUrl = `${baseUrl}/branches/${encodeURIComponent(branchName)}/trends/`;
} else {
fullUrl = `${baseUrl}/trends/`;
}
Fetch.fetchJSON(fullUrl).then(data => this._loadTrendsSuccess(data));
}
constructor(props) {
super(props);
this.state = {
credential: null,
credentialError: null,
};
this.restOrgPrefix = AppConfig.getRestRoot() + '/organizations/' + AppConfig.getOrganizationName();
}
export const generateDetailUrl = (pipeline, branch, runId) => {
const baseUrl = `${AppConfig.getRestRoot()}/organizations/${pipeline.organization}/` + `pipelines/${pipeline.fullName}`;
const isMultiBranchPipeline = capable(pipeline, MULTIBRANCH_PIPELINE);
let returnUrl;
if (isMultiBranchPipeline) {
returnUrl = `${baseUrl}/branches/${UrlUtils.doubleUriEncode(branch)}/runs/${runId}`;
} else {
returnUrl = `${baseUrl}/runs/${runId}`;
}
logger.debug(returnUrl);
return returnUrl;
};