From de81437248fa04578330b96e932d14f5aaefb19b Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 20 Nov 2021 11:47:19 +0900 Subject: [PATCH] Fix #31 --- src/streaming.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/streaming.ts b/src/streaming.ts index 2e12d0b..3807a72 100644 --- a/src/streaming.ts +++ b/src/streaming.ts @@ -1,13 +1,17 @@ import autobind from 'autobind-decorator'; import { EventEmitter } from 'eventemitter3'; import ReconnectingWebsocket from 'reconnecting-websocket'; -import { stringify } from 'querystring'; import { BroadcastEvents, Channels } from './streaming.types'; -function urlQuery(obj: Record): string { - return stringify(Object.entries(obj) +export function urlQuery(obj: Record): string { + const params = Object.entries(obj) .filter(([, v]) => Array.isArray(v) ? v.length : v !== undefined) - .reduce((a, [k, v]) => (a[k] = v, a), {} as Record)); + .reduce((a, [k, v]) => (a[k] = v, a), {} as Record); + + return Object.entries(params) + .map((e) => `${e[0]}=${e[1]}`) + .map((e) => `${e[0]}=${encodeURIComponent(e[1])}`) + .join('&'); } type AnyOf> = T[keyof T];