mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-21 17:37:29 -07:00
[backend] Fix emojis with special characters
This is an adaptation of3968a6ca07
andada577bde6
Co-authored-by: Johann150 <johann.galle@protonmail.com>
This commit is contained in:
parent
299a20fb71
commit
197002df8a
2 changed files with 7 additions and 8 deletions
|
@ -41,13 +41,10 @@ function normalizeHost(
|
|||
}
|
||||
|
||||
function parseEmojiStr(emojiName: string, noteUserHost: string | null) {
|
||||
const match = emojiName.match(/^(\w+)(?:@([\w.-]+))?$/);
|
||||
if (!match) return { name: null, host: null };
|
||||
|
||||
const name = match[1];
|
||||
|
||||
// ホスト正規化
|
||||
const host = toPunyNullable(normalizeHost(match[2], noteUserHost));
|
||||
// emojiName may be of the form `emoji@host`, turn it into a suitable form
|
||||
const match = emojiName.split("@");
|
||||
const name = match[0];
|
||||
const host = toPunyNullable(normalizeHost(match[1], noteUserHost));
|
||||
|
||||
return { name, host };
|
||||
}
|
||||
|
|
|
@ -68,7 +68,9 @@ export async function exportCustomEmojis(
|
|||
|
||||
for (const emoji of customEmojis) {
|
||||
const ext = mime.extension(emoji.type);
|
||||
const fileName = emoji.name + (ext ? `.${ext}` : "");
|
||||
// there are some restrictions on file names, so to be safe the files are
|
||||
// named after their database id instead of the actual emoji name
|
||||
const fileName = emoji.id + (ext ? '.' + ext : '');
|
||||
const emojiPath = `${path}/${fileName}`;
|
||||
fs.writeFileSync(emojiPath, "", "binary");
|
||||
let downloaded = false;
|
||||
|
|
Loading…
Reference in a new issue