[JENKINS-37838] Calls to backend MUST end with / (#454)

* [JENKINS-37838] Calls to backend MUST end with /

* Append / to all urls in function
This commit is contained in:
Ivan Meredith 2016-09-01 12:37:36 +12:00 committed by GitHub
parent 898c368656
commit 88cbacd967
1 changed files with 15 additions and 15 deletions

View File

@ -161,6 +161,20 @@ export function paginateUrl(url) {
return (start, limit) => `${url}${sep}start=${start}&limit=${limit}`;
}
/**
* Returns a new string which ends with a slash, or the
* original if it already does
*/
export function endSlash(str) {
if (!str) {
return str;
}
if (str.charAt(str.length - 1) !== '/') {
return `${str}/`;
}
return str;
}
/**
* Examines the provided object for:
* organization, pipeline, branch, runId
@ -183,21 +197,7 @@ export function getRestUrl({ organization, pipeline, branch, runId }) {
if (runId) {
url += `/runs/${encodeURIComponent(runId)}`;
}
return url;
}
/**
* Returns a new string which ends with a slash, or the
* original if it already does
*/
export function endSlash(str) {
if (!str) {
return str;
}
if (str.charAt(str.length - 1) !== '/') {
return `${str}/`;
}
return str;
return endSlash(url);
}
/**