MCPcopy Create free account
hub / github.com/remix-run/react-router / toSlug

Function toSlug

scripts/changes/add.ts:193–204  ·  view source on GitHub ↗

* Converts a free-text description into a kebab-case slug of at most 6 * meaningful words. Stop words and non-alphanumeric characters are stripped.

(description: string)

Source from the content-addressed store, hash-verified

191 * meaningful words. Stop words and non-alphanumeric characters are stripped.
192 */
193function toSlug(description: string): string {
194 return (
195 description
196 .toLowerCase()
197 .replace(/[^a-z0-9\s]/g, "")
198 .trim()
199 .split(/\s+/)
200 .filter((w) => !STOP_WORDS.has(w))
201 .slice(0, 6)
202 .join("-") || "change"
203 );
204}

Callers 1

add.tsFile · 0.85

Calls 2

hasMethod · 0.80
replaceMethod · 0.65

Tested by

no test coverage detected