mirror of
https://github.com/danbulant/discord.js
synced 2026-05-27 22:11:53 +00:00
refactor(WebSocket): utilize URLSearchParams (#3185)
* replace querystring with URLSearchParams * looks a bit nicer using urlSearchParams.set(...)
This commit is contained in:
parent
00eb7e325a
commit
152d2e88bd
1 changed files with 3 additions and 3 deletions
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue