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: {