Add Slugify to turn text into a lowercase hyphenated slug #9
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Turning a title into something safe for a URL path, a filename or an anchor
comes up in every project that publishes anything, and the hand-rolled versions
tend to leave a trailing hyphen or let a stray character through. The repo
already has
FilterToAlnum, which throws separators away entirely, so afunction that keeps word boundaries as hyphens is a natural companion.
Definition of done:
Slugify(input string) stringreturns a string oflowercase ASCII letters, digits and single hyphens, where every run of other
characters becomes one hyphen and there are no hyphens at the start or end. It
has a doc comment and table-driven tests covering mixed case, punctuation, runs
of separators, leading and trailing separators, a string with nothing usable in
it, an empty string, and text outside ASCII.
Model: opus-5