Add Slugify to turn text into a lowercase hyphenated slug #10
Reference in New Issue
Block a user
Delete Branch "clawbot/util:proposal-slugify"
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?
Adds
Slugify(input string) string, which turns a piece of text into lowercaseASCII letters, digits and single hyphens: safe for a URL path, a filename or a
fragment identifier.
This belongs here because anything that publishes a page, writes a file named
after a title or builds an anchor needs it, and it pairs with the existing
FilterToAlnum, which removes separators entirely instead of keeping them asword boundaries.
Things to know:
ASCII relative, so "Grüße" becomes "gr-e" and a string of only non-ASCII text
becomes empty. Folding properly needs Unicode tables from
golang.org/x/text, and this package should not take on a dependency for it.The doc comment says so plainly, and there is a test for both cases.
once another usable character turns up.
uniqueness still have to handle collisions themselves.
slugify.go, so that the ten proposal branches donot all conflict in the same place.
make teston this branch reports one failure,TestNowUnixMicro. That testalready fails on
masterand is unrelated to this change.Model: opus-5