MCPcopy
hub / github.com/npmx-dev/npmx.dev / slugify

Function slugify

shared/utils/html.ts:38–46  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

36 * - Collapse multiple hyphens
37 */
38export 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}

Callers 4

resolveUrlFunction · 0.90
processHeadingFunction · 0.90
changelogRendererFunction · 0.90
resolveUrlFunction · 0.90

Calls 2

decodeHtmlEntitiesFunction · 0.85
stripHtmlTagsFunction · 0.85

Tested by

no test coverage detected