Skip to content

Commit

Permalink
chore: remove trailing "/" from cluster config url's if needed (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
tremes authored and lholmquist committed Dec 12, 2018
1 parent a30312a commit 363ca5a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/config-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -63,4 +64,8 @@ function loadConfig (client) {
});
}

function removeTrailingSlash (url) {
return url.endsWith('/') ? url.slice(0, url.length - 1) : url;
}

module.exports = loadConfig;

0 comments on commit 363ca5a

Please sign in to comment.