Skip to content

Commit 68356d1

Browse files
committed
feat: Replace last character of '/' If exists
1 parent 295b1ea commit 68356d1

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/config_types.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as fs from 'fs';
22
import * as _ from 'underscore';
3-
import {URL} from 'url';
43

54
export enum ActionOnInvalid {
65
THROW = 'throw',
@@ -28,10 +27,7 @@ export interface Cluster {
2827
export function newClusters(a: any, opts?: Partial<ConfigOptions>): Cluster[] {
2928
const options = Object.assign(defaultNewConfigOptions(), opts || {});
3029

31-
return _.compact(_.map(a, clusterIterator(options.onInvalidEntry))).map((cluster) => ({
32-
...cluster,
33-
server: new URL(cluster.server).origin,
34-
}));
30+
return _.compact(_.map(a, clusterIterator(options.onInvalidEntry)));
3531
}
3632

3733
export function exportCluster(cluster: Cluster): any {
@@ -62,7 +58,7 @@ function clusterIterator(onInvalidEntry: ActionOnInvalid): _.ListIterator<any, C
6258
caData: elt.cluster['certificate-authority-data'],
6359
caFile: elt.cluster['certificate-authority'],
6460
name: elt.name,
65-
server: elt.cluster.server,
61+
server: elt.cluster.server.replace(/\/$/, ''),
6662
skipTLSVerify: elt.cluster['insecure-skip-tls-verify'] === true,
6763
};
6864
} catch (err) {

0 commit comments

Comments
 (0)