mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
3739def43f
Use rune-aware truncation for user-facing text and log previews so multibyte content is not corrupted in memory context, Telegram messages, or diagnostics.
19 lines
428 B
Go
19 lines
428 B
Go
// Package common provides shared utilities for channel adapters.
|
|
package common
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/memohai/memoh/internal/textutil"
|
|
)
|
|
|
|
// SummarizeText returns a truncated preview of the text, limited to 120 characters.
|
|
func SummarizeText(text string) string {
|
|
value := strings.TrimSpace(text)
|
|
if value == "" {
|
|
return ""
|
|
}
|
|
const limit = 120
|
|
return textutil.TruncateRunesWithSuffix(value, limit, "...")
|
|
}
|