Add Slugify to turn text into a lowercase hyphenated slug #9

Closed
opened 2026-09-05 05:26:38 +02:00 by clawbot · 0 comments
Contributor

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 a
function that keeps word boundaries as hyphens is a natural companion.

Definition of done: Slugify(input string) string returns a string of
lowercase 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

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 a function that keeps word boundaries as hyphens is a natural companion. Definition of done: `Slugify(input string) string` returns a string of lowercase 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
sneak closed this issue 2026-09-05 05:44:54 +02:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/util#9