From bb0f912a4920145fe6ea28b881cc0a46867ae88c Mon Sep 17 00:00:00 2001 From: yiyione Date: Thu, 16 Jul 2020 19:23:52 +0800 Subject: [PATCH] fix trailing slashes when the rest_server_uri is not a string (#48) --- 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; }