From bce664ba03f4362f3c522fab966f19a4cbc768df Mon Sep 17 00:00:00 2001 From: Yi Yi Date: Thu, 16 Jul 2020 14:55:31 +0800 Subject: [PATCH] fix trailing slashes when the rest_server_uri is not a string --- src/api/v2/clients/baseClient.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/api/v2/clients/baseClient.ts b/src/api/v2/clients/baseClient.ts index 1456629..7982e61 100644 --- a/src/api/v2/clients/baseClient.ts +++ b/src/api/v2/clients/baseClient.ts @@ -30,6 +30,12 @@ export class OpenPAIBaseClient { constructor(cluster: IPAICluster) { this.cluster = OpenPAIBaseClient.parsePaiUri(cluster); this.httpClient = new PAIHttpClient(cluster); + + if (this.cluster.rest_server_uri) { + this.cluster.rest_server_uri = this.cluster.rest_server_uri + .toString() + .replace(/\/+$/, ''); + } } /** @@ -48,8 +54,6 @@ export class OpenPAIBaseClient { if (!cluster.alias) { cluster.alias = paiUri.hostname; } - - cluster.rest_server_uri = cluster.rest_server_uri.replace(/\/+$/, ''); } return cluster; }