(text: string)
| 36 | * - Collapse multiple hyphens |
| 37 | */ |
| 38 | export function slugify(text: string): string { |
| 39 | return decodeHtmlEntities(stripHtmlTags(text)) |
| 40 | .toLowerCase() |
| 41 | .trim() |
| 42 | .replace(/\s+/g, '-') // Spaces to hyphens |
| 43 | .replace(/[^\w\u4e00-\u9fff\u3040-\u309f\u30a0-\u30ff-]/g, '') // Keep alphanumeric, CJK, hyphens |
| 44 | .replace(/-+/g, '-') // Collapse multiple hyphens |
| 45 | .replace(/^-|-$/g, '') // Trim leading/trailing hyphens |
| 46 | } |
no test coverage detected