diff --git a/lib/backends/request.js b/lib/backends/request.js index e46eff04..de9dc5d6 100644 --- a/lib/backends/request.js +++ b/lib/backends/request.js @@ -2,6 +2,7 @@ const request = require('request') const qs = require('qs') +const urljoin = require('url-join') const WebSocket = require('ws') /** @@ -56,7 +57,7 @@ function isUpgradeRequired (body) { function upgradeRequest (options, cb) { const queryParams = qs.stringify(options.qs, { indices: false }) - const wsUrl = `${options.baseUrl}/${options.uri}?${queryParams}` + const wsUrl = urljoin(options.baseUrl, options.uri, `?${queryParams}`) const protocol = 'base64.channel.k8s.io' const ws = new WebSocket(wsUrl, protocol, options) diff --git a/package-lock.json b/package-lock.json index 78269969..c647be9c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5082,6 +5082,11 @@ "punycode": "^2.1.0" } }, + "url-join": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/url-join/-/url-join-4.0.0.tgz", + "integrity": "sha1-TTNA6AfTdzvamZH4MFrNzCpmXSo=" + }, "url-parse-lax": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-3.0.0.tgz", diff --git a/package.json b/package.json index 3f1a3176..b6ad2daf 100644 --- a/package.json +++ b/package.json @@ -32,11 +32,12 @@ ], "dependencies": { "deepmerge": "^3.0.0", - "swagger-fluent": "^3.1.1", "js-yaml": "^3.10.0", "openid-client": "^2.4.4", "qs": "^6.5.2", "request": "^2.88.0", + "swagger-fluent": "^3.1.1", + "url-join": "^4.0.0", "ws": "^6.0.0" }, "devDependencies": {