8b46edeccf
* fix(server): /emoji to accept `@.` host expression
* fix(client): use MkEmoji for custom emoji in MkEmojiPicker
* change convertToWebp
* nanka iroiro
* remove
* fix
* nearLosslessは労多くして益少なしなのでやめる
* do not cleanup tmp for development
* update sharp.js to 0.31.3
* mixed: true
* fix MkAutocomplete of 912791b3ab
* clean up
* https://github.com/misskey-dev/misskey/pull/9431#discussion_r1059215943
19 lines
719 B
TypeScript
19 lines
719 B
TypeScript
/* objを検査して
|
||
* 1. 配列に何も入っていない時はクエリを付けない
|
||
* 2. プロパティがundefinedの時はクエリを付けない
|
||
* (new URLSearchParams(obj)ではそこまで丁寧なことをしてくれない)
|
||
*/
|
||
export function query(obj: object): 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<string, any>);
|
||
|
||
return Object.entries(params)
|
||
.map((e) => `${e[0]}=${encodeURIComponent(e[1])}`)
|
||
.join('&');
|
||
}
|
||
|
||
export function appendQuery(url: string, query: string): string {
|
||
return `${url}${/\?/.test(url) ? url.endsWith('?') ? '' : '&' : '?'}${query}`;
|
||
}
|