mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 16:43:31 +01:00
refactor(WebSocket): utilize URLSearchParams (#3185)
* replace querystring with URLSearchParams * looks a bit nicer using urlSearchParams.set(...)
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const { browser } = require('./util/Constants');
|
||||
const querystring = require('querystring');
|
||||
try {
|
||||
var erlpack = require('erlpack');
|
||||
if (!erlpack.pack) erlpack = null;
|
||||
@@ -30,8 +29,9 @@ exports.unpack = data => {
|
||||
exports.create = (gateway, query = {}, ...args) => {
|
||||
const [g, q] = gateway.split('?');
|
||||
query.encoding = exports.encoding;
|
||||
if (q) query = Object.assign(querystring.parse(q), query);
|
||||
const ws = new exports.WebSocket(`${g}?${querystring.stringify(query)}`, ...args);
|
||||
query = new URLSearchParams(query);
|
||||
if (q) new URLSearchParams(q).forEach((v, k) => query.set(k, v));
|
||||
const ws = new exports.WebSocket(`${g}?${query}`, ...args);
|
||||
if (browser) ws.binaryType = 'arraybuffer';
|
||||
return ws;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user