mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-11 17:26:45 +02:00
Refactor emoji removal logic into a shared utility and update dependencies. Replit-Commit-Author: Agent Replit-Commit-Session-Id: ae4037a0-2a6f-4530-9bac-79b543286bda Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Event-Id: 59d8c635-691c-42a3-b368-902e8f16eeee Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/397bca8c-984f-43ff-841a-10897aeb8140/ae4037a0-2a6f-4530-9bac-79b543286bda/Q6FJ7Lw
17 lines
502 B
TypeScript
17 lines
502 B
TypeScript
import emojiRegex from 'emoji-regex';
|
|
|
|
// Cached regex instance for performance
|
|
const emojiPattern = emojiRegex();
|
|
|
|
/**
|
|
* Removes emojis from text while preserving other Unicode characters
|
|
* Uses the emoji-regex package which correctly identifies emojis without
|
|
* removing legitimate astral-plane characters (CJK Extension B, etc.)
|
|
*/
|
|
export function removeEmojis(text: string): string {
|
|
return text
|
|
.replace(emojiPattern, '')
|
|
.replace(/\s+/g, ' ') // Normalize whitespace
|
|
.trim();
|
|
}
|