1
0
mirror of https://github.com/misskey-dev/misskey synced 2024-12-16 23:59:05 +09:00
misskey/src/prelude/url.ts
tamaina de47a17be7 Improve drive downloading (#4523)
* Improve drive file downloading

* fix name

* wtf crlf

* semicolon
2019-03-18 13:20:49 +09:00

12 lines
409 B
TypeScript

import { stringify } from 'querystring';
export function query(obj: {}): string {
return stringify(Object.entries(obj)
.filter(([, v]) => Array.isArray(v) ? v.length : v !== undefined)
.reduce((a, [k, v]) => (a[k] = v, a), {} as Record<string, any>));
}
export function appendQuery(url: string, query: string): string {
return `${url}${/\?/.test(url) ? url.endsWith('?') ? '' : '&' : '?'}${query}`;
}