1
0
mirror of https://github.com/misskey-dev/misskey synced 2024-11-25 07:37:13 +09:00

refactor: prelude/urlでquerystringを使用しないように

Resolve #7854
This commit is contained in:
syuilo 2021-10-01 00:31:43 +09:00
parent 4fd4132f5e
commit bd9df789d1

View File

@ -1,9 +1,11 @@
import { stringify } from 'querystring';
export function query(obj: {}): string {
return stringify(Object.entries(obj)
const params = Object.entries(obj)
.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, any>);
return Object.entries(params)
.map((e) => `${e[0]}=${e[1]}`)
.join('&');
}
export function appendQuery(url: string, query: string): string {