mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-30 23:09:19 +09:00
Fix #31
This commit is contained in:
parent
043ffe3a2e
commit
de81437248
@ -1,13 +1,17 @@
|
|||||||
import autobind from 'autobind-decorator';
|
import autobind from 'autobind-decorator';
|
||||||
import { EventEmitter } from 'eventemitter3';
|
import { EventEmitter } from 'eventemitter3';
|
||||||
import ReconnectingWebsocket from 'reconnecting-websocket';
|
import ReconnectingWebsocket from 'reconnecting-websocket';
|
||||||
import { stringify } from 'querystring';
|
|
||||||
import { BroadcastEvents, Channels } from './streaming.types';
|
import { BroadcastEvents, Channels } from './streaming.types';
|
||||||
|
|
||||||
function urlQuery(obj: Record<string, unknown>): string {
|
export function urlQuery(obj: Record<string, unknown>): string {
|
||||||
return stringify(Object.entries(obj)
|
const params = Object.entries(obj)
|
||||||
.filter(([, v]) => Array.isArray(v) ? v.length : v !== undefined)
|
.filter(([, v]) => Array.isArray(v) ? v.length : v !== undefined)
|
||||||
.reduce((a, [k, v]) => (a[k] = v, a), {} as Record<string, any>));
|
.reduce((a, [k, v]) => (a[k] = v, a), {} as Record<string, unknown>);
|
||||||
|
|
||||||
|
return Object.entries(params)
|
||||||
|
.map((e) => `${e[0]}=${e[1]}`)
|
||||||
|
.map((e) => `${e[0]}=${encodeURIComponent(e[1])}`)
|
||||||
|
.join('&');
|
||||||
}
|
}
|
||||||
|
|
||||||
type AnyOf<T extends Record<any, any>> = T[keyof T];
|
type AnyOf<T extends Record<any, any>> = T[keyof T];
|
||||||
|
Loading…
Reference in New Issue
Block a user