From ef04a94a690e45a1374d24031b9026c871a56530 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Mon, 12 Jan 2026 14:47:34 +0700 Subject: [PATCH] fix:function removeDuplicateWords --- src/modules/05_leave/components/FormLeave/Form.vue | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/modules/05_leave/components/FormLeave/Form.vue b/src/modules/05_leave/components/FormLeave/Form.vue index dc834c6..f1824e8 100644 --- a/src/modules/05_leave/components/FormLeave/Form.vue +++ b/src/modules/05_leave/components/FormLeave/Form.vue @@ -22,19 +22,8 @@ const { date2Thai, messageError } = useCounterMixin(); function removeDuplicateWords(text: string): string { if (!text) return text; - // แยกคำด้วยการหาคำที่ซ้ำติดกัน - const words = text.split(/(?=[ก-๙])/); - const result: string[] = []; - - for (let i = 0; i < words.length; i++) { - const word = words[i]; - if (i === 0 || word !== words[i - 1]) { - result.push(word); - } - } - // วิธีที่ดีกว่า: ใช้ regex เพื่อหาและลบคำที่ซ้ำ - return text.replace(/([ก-๙]+)\1+/g, "$1"); + return text.replace(/([ก-๙]{2,})\1+/g, "$1"); } /** รับ props มาจากหน้าหลัก */