summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2023-02-03 17:44:25 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2023-02-03 17:44:25 +0900
commit1d39f785f1610eea36126a8e8d1fe651e0e184dd (patch)
treecdda1fb5546fc1bd9661a287a1b5413813450303 /packages
parentUpdate CHANGELOG.md (diff)
downloadmisskey-1d39f785f1610eea36126a8e8d1fe651e0e184dd.tar.gz
misskey-1d39f785f1610eea36126a8e8d1fe651e0e184dd.tar.bz2
misskey-1d39f785f1610eea36126a8e8d1fe651e0e184dd.zip
perf: use replaceAll instead of regex
Diffstat (limited to 'packages')
-rw-r--r--packages/backend/src/core/activitypub/ApRendererService.ts2
-rw-r--r--packages/backend/src/misc/nyaize.ts4
2 files changed, 3 insertions, 3 deletions
diff --git a/packages/backend/src/core/activitypub/ApRendererService.ts b/packages/backend/src/core/activitypub/ApRendererService.ts
index 91a2767e69..648f30229a 100644
--- a/packages/backend/src/core/activitypub/ApRendererService.ts
+++ b/packages/backend/src/core/activitypub/ApRendererService.ts
@@ -274,7 +274,7 @@ export class ApRendererService {
} as any;
if (reaction.startsWith(':')) {
- const name = reaction.replace(/:/g, '');
+ const name = reaction.replaceAll(':', '');
const emoji = await this.emojisRepository.findOneBy({
name,
host: IsNull(),
diff --git a/packages/backend/src/misc/nyaize.ts b/packages/backend/src/misc/nyaize.ts
index 500d1db2cb..350f8d2172 100644
--- a/packages/backend/src/misc/nyaize.ts
+++ b/packages/backend/src/misc/nyaize.ts
@@ -1,14 +1,14 @@
export function nyaize(text: string): string {
return text
// ja-JP
- .replace(/な/g, 'にゃ').replace(/ナ/g, 'ニャ').replace(/ナ/g, 'ニャ')
+ .replaceAll('な', 'にゃ').replaceAll('ナ', 'ニャ').replaceAll('ナ', 'ニャ')
// en-US
.replace(/(?<=n)a/gi, x => x === 'A' ? 'YA' : 'ya')
.replace(/(?<=morn)ing/gi, x => x === 'ING' ? 'YAN' : 'yan')
.replace(/(?<=every)one/gi, x => x === 'ONE' ? 'NYAN' : 'nyan')
// ko-KR
.replace(/[나-낳]/g, match => String.fromCharCode(
- match.charCodeAt(0)! + '냐'.charCodeAt(0) - '나'.charCodeAt(0)
+ match.charCodeAt(0)! + '냐'.charCodeAt(0) - '나'.charCodeAt(0),
))
.replace(/(다$)|(다(?=\.))|(다(?= ))|(다(?=!))|(다(?=\?))/gm, '다냥')
.replace(/(야(?=\?))|(야$)|(야(?= ))/gm, '냥');