summaryrefslogtreecommitdiff
path: root/packages/backend/src
diff options
context:
space:
mode:
authorCocoa Hoto <cocoa@hoto.us>2024-04-25 11:03:34 +0900
committerGitHub <noreply@github.com>2024-04-25 11:03:34 +0900
commit85339ca751401ff856814ca21283c07a7c66f5ce (patch)
tree845981f7a2baa3c2e259597e47a47a68c2750e4e /packages/backend/src
parentAiScriptのバージョンを0.18.0に上げる (#13743) (diff)
downloadsharkey-85339ca751401ff856814ca21283c07a7c66f5ce.tar.gz
sharkey-85339ca751401ff856814ca21283c07a7c66f5ce.tar.bz2
sharkey-85339ca751401ff856814ca21283c07a7c66f5ce.zip
feat: improve emoji endpoint (#13742)
Diffstat (limited to 'packages/backend/src')
-rw-r--r--packages/backend/src/server/ServerService.ts14
1 files changed, 11 insertions, 3 deletions
diff --git a/packages/backend/src/server/ServerService.ts b/packages/backend/src/server/ServerService.ts
index 671dd31eb1..1324cd1361 100644
--- a/packages/backend/src/server/ServerService.ts
+++ b/packages/backend/src/server/ServerService.ts
@@ -120,12 +120,20 @@ export class ServerService implements OnApplicationShutdown {
return;
}
- const name = path.split('@')[0].replace(/\.webp$/i, '');
- const host = path.split('@')[1]?.replace(/\.webp$/i, '');
+ const emojiPath = path.replace(/\.webp$/i, '');
+ const pathChunks = emojiPath.split('@');
+
+ if (pathChunks.length > 2) {
+ reply.code(400);
+ return;
+ }
+
+ const name = pathChunks.shift();
+ const host = pathChunks.pop();
const emoji = await this.emojisRepository.findOneBy({
// `@.` is the spec of ReactionService.decodeReaction
- host: (host == null || host === '.') ? IsNull() : host,
+ host: (host === undefined || host === '.') ? IsNull() : host,
name: name,
});