From 5556117dd06303d2376ad36fa75d307b64938751 Mon Sep 17 00:00:00 2001 From: Antoine Arlaud Date: Mon, 5 Jun 2023 19:07:24 +0200 Subject: [PATCH] fix: properly structure qs params in dispatcher calls --- lib/dispatcher.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/dispatcher.js b/lib/dispatcher.js index dbcceb48c..396a2808d 100644 --- a/lib/dispatcher.js +++ b/lib/dispatcher.js @@ -49,17 +49,22 @@ class DispatcherClient { time = -1, ) { const hashedToken = hashToken(token); - let queryStringParams = clientId - ? `?broker_client_id=${clientId}&request_type=${requestType}` - : ''; + const url = new URL( + `${this.#url}/internal/brokerservers/${ + this.#id + }/connections/${hashedToken}`, + ); + if (clientId) { + url.searchParams.append('broker_client_id', clientId); + } if (time != -1) { - queryStringParams = queryStringParams + `&latency=${Date.now() - time}`; + url.searchParams.append('latency', Date.now() - time); } + url.searchParams.append('request_type', requestType); + await this.#makeRequest( { hashedToken, clientId, requestType: requestType }, - `${this.#url}/internal/brokerservers/${ - this.#id - }/connections/${hashedToken}${queryStringParams}`, + url.toString(), 'post', { data: {