Fix query string on requests after ratelimited (#2215)

* Fix querystring being appended multiple times when ratelimited

* Better way?

* Better better way

* Fix empty queries
This commit is contained in:
1Computer1
2018-01-03 19:17:15 -05:00
committed by Crawl
parent 45127bb408
commit 01f1f1b58e

View File

@@ -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());