From 2645b30fb32badf5067c47a19fd734586fb93168 Mon Sep 17 00:00:00 2001 From: Ljzd PRO <63289359+Ljzd-PRO@users.noreply.github.com> Date: Mon, 16 Sep 2024 23:40:41 +0800 Subject: [PATCH] fix: fix Invalid regular expression on iOS <= 16.3 --- packages/misskey-js/src/nyaize.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/misskey-js/src/nyaize.ts b/packages/misskey-js/src/nyaize.ts index 729fea8fc3..e346f5505a 100644 --- a/packages/misskey-js/src/nyaize.ts +++ b/packages/misskey-js/src/nyaize.ts @@ -3,9 +3,6 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -const enRegex1 = /(?<=n)a/gi; -const enRegex2 = /(?<=morn)ing/gi; -const enRegex3 = /(?<=every)one/gi; const koRegex1 = /[나-낳]/g; const koRegex2 = /(다$)|(다(?=\.))|(다(?= ))|(다(?=!))|(다(?=\?))/gm; const koRegex3 = /(야(?=\?))|(야$)|(야(?= ))/gm; @@ -15,9 +12,12 @@ export function nyaize(text: string): string { // ja-JP .replaceAll('な', 'にゃ').replaceAll('ナ', 'ニャ').replaceAll('ナ', 'ニャ') // en-US - .replace(enRegex1, x => x === 'A' ? 'YA' : 'ya') - .replace(enRegex2, x => x === 'ING' ? 'YAN' : 'yan') - .replace(enRegex3, x => x === 'ONE' ? 'NYAN' : 'nyan') + .replaceAll('na', 'nya') + .replaceAll('NA', 'NYA') + .replaceAll('morning', 'mornyan') + .replaceAll('MORNING', 'MORNYAN') + .replaceAll('everyone', 'everynyan') + .replaceAll('EVERYONE', 'EVERYNYAN') // ko-KR .replace(koRegex1, match => !isNaN(match.charCodeAt(0)) ? String.fromCharCode( match.charCodeAt(0) + '냐'.charCodeAt(0) - '나'.charCodeAt(0),