diff --git a/lib/config-loader.js b/lib/config-loader.js index 50fab3d..44e32db 100644 --- a/lib/config-loader.js +++ b/lib/config-loader.js @@ -33,9 +33,10 @@ function load (settings) { // Returns a promise function loadConfig (client) { return load(client.settings).then((config) => { - client.apiUrl = `${config.cluster}/oapi/${config.apiVersion}`; - client.kubeUrl = `${config.cluster}/api/${config.apiVersion}`; - client.authUrl = `${config.cluster}/oauth/authorize?response_type=token&client_id=openshift-challenging-client`; + const clusterUrl = removeTrailingSlash(config.cluster); + client.apiUrl = `${clusterUrl}/oapi/${config.apiVersion}`; + client.kubeUrl = `${clusterUrl}/api/${config.apiVersion}`; + client.authUrl = `${clusterUrl}/oauth/authorize?response_type=token&client_id=openshift-challenging-client`; client.apis = { oapi: { version: config.apiVersion, @@ -63,4 +64,8 @@ function loadConfig (client) { }); } +function removeTrailingSlash (url) { + return url.endsWith('/') ? url.slice(0, url.length - 1) : url; +} + module.exports = loadConfig;