From f0dc0ddcb0ae8bffd8e21468a5de4e09ecba2d4d Mon Sep 17 00:00:00 2001 From: le2yunji Date: Sun, 18 Jan 2026 01:08:23 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Fix:=20=EC=95=8C=EB=A6=BC=20=EC=A0=9C?= =?UTF-8?q?=EB=AA=A9=20=EB=84=98=EC=B9=A8=20=EC=A0=9C=EC=96=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/Header/NotificationContent.tsx | 6 ++++- src/utils/stringUtils.ts | 25 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 src/utils/stringUtils.ts diff --git a/src/components/common/Header/NotificationContent.tsx b/src/components/common/Header/NotificationContent.tsx index 536ce94..cf466d0 100644 --- a/src/components/common/Header/NotificationContent.tsx +++ b/src/components/common/Header/NotificationContent.tsx @@ -1,3 +1,5 @@ +import { truncateByChar } from '@/utils/stringUtils'; + // 알림 콘텐츠 파싱 결과 타입 interface ParsedNotification { type: 'parsed' | 'raw'; @@ -64,7 +66,9 @@ const NotificationContent = ({ content }: { content: string }) => { return (

{parsed.status}

-

{parsed.title}

+

+ {truncateByChar(parsed.title!, 13)} +

({parsed.time})

diff --git a/src/utils/stringUtils.ts b/src/utils/stringUtils.ts new file mode 100644 index 0000000..07d62fe --- /dev/null +++ b/src/utils/stringUtils.ts @@ -0,0 +1,25 @@ +export const truncateByChar = (text: string, limit = 13) => { + if (!text) { + return ''; + } + + const chars = Array.from(text); + let count = 0; + let result = ''; + + for (const char of chars) { + // 공백은 글자 수에서 제외 + if (char !== ' ') { + count += 1; + } + + // limit 초과 시 말줄임 + if (count > limit) { + return result + '…'; + } + + result += char; + } + + return result; +}; From c4be368a5a210340588aedd7173cf14d6ec23e02 Mon Sep 17 00:00:00 2001 From: le2yunji Date: Sun, 18 Jan 2026 01:17:57 +0900 Subject: [PATCH 2/2] =?UTF-8?q?Fix:=20=EC=A0=9C=EB=AF=B8=EB=82=98=EC=9D=B4?= =?UTF-8?q?=20=EC=BD=94=EB=93=9C=EB=A6=AC=EB=B7=B0=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/Header/NotificationContent.tsx | 4 ++-- src/utils/stringUtils.ts | 23 ++++++++----------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/components/common/Header/NotificationContent.tsx b/src/components/common/Header/NotificationContent.tsx index cf466d0..a11840f 100644 --- a/src/components/common/Header/NotificationContent.tsx +++ b/src/components/common/Header/NotificationContent.tsx @@ -66,8 +66,8 @@ const NotificationContent = ({ content }: { content: string }) => { return (

{parsed.status}

-

- {truncateByChar(parsed.title!, 13)} +

+ {truncateByChar(parsed.title, 13)}

({parsed.time})

diff --git a/src/utils/stringUtils.ts b/src/utils/stringUtils.ts index 07d62fe..b9c0651 100644 --- a/src/utils/stringUtils.ts +++ b/src/utils/stringUtils.ts @@ -1,25 +1,20 @@ -export const truncateByChar = (text: string, limit = 13) => { +export const truncateByChar = (text: string | undefined, limit = 13) => { if (!text) { return ''; } const chars = Array.from(text); - let count = 0; - let result = ''; - - for (const char of chars) { - // 공백은 글자 수에서 제외 + let nonSpaceCount = 0; + const truncateIndex = chars.findIndex((char) => { if (char !== ' ') { - count += 1; - } - - // limit 초과 시 말줄임 - if (count > limit) { - return result + '…'; + nonSpaceCount++; } + return nonSpaceCount > limit; + }); - result += char; + if (truncateIndex === -1) { + return text; } - return result; + return chars.slice(0, truncateIndex).join('') + '…'; };