From 01f1f1b58e5b4a3ba5de77c85802520ab4cafee3 Mon Sep 17 00:00:00 2001 From: 1Computer1 <1Computer1@users.noreply.github.com> Date: Wed, 3 Jan 2018 19:17:15 -0500 Subject: [PATCH] Fix query string on requests after ratelimited (#2215) * Fix querystring being appended multiple times when ratelimited * Better way? * Better better way * Fix empty queries --- src/rest/APIRequest.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/rest/APIRequest.js b/src/rest/APIRequest.js index ae4a352f3..e0527320d 100644 --- a/src/rest/APIRequest.js +++ b/src/rest/APIRequest.js @@ -10,20 +10,17 @@ class APIRequest { this.rest = rest; this.client = rest.client; this.method = method; - this.path = path.toString(); this.route = options.route; this.options = options; + + const queryString = (querystring.stringify(options.query).match(/[^=&?]+=[^=&?]+/g) || []).join('&'); + this.path = `${path}${queryString ? `?${queryString}` : ''}`; } gen() { const API = this.options.versioned === false ? this.client.options.http.api : `${this.client.options.http.api}/v${this.client.options.http.version}`; - if (this.options.query) { - const queryString = (querystring.stringify(this.options.query).match(/[^=&?]+=[^=&?]+/g) || []).join('&'); - this.path += `?${queryString}`; - } - const request = snekfetch[this.method](`${API}${this.path}`, { agent }); if (this.options.auth !== false) request.set('Authorization', this.rest.getAuth());