Skip to content

Latest commit

 

History

History
28 lines (21 loc) · 1.14 KB

README.md

File metadata and controls

28 lines (21 loc) · 1.14 KB

Slug

slug builds an ASCII kebab-case string. The implementation note is slug/readme.md.

DefaultMaxLength is 50. UUIDPrefixLength is 8.

Normalize returns "" for empty text or a maxLength that is not positive. Otherwise it removes Unicode marks, lowercases the text, turns every run of characters outside a-z and 0-9 into one hyphen, and trims hyphens. A result longer than maxLength is cut at the last hyphen that remains inside that limit, or at maxLength when no hyphen remains, and then trimmed again.

Generate normalizes the text with DefaultMaxLength and appends - plus the first 8 characters of id.String(). An empty normalization returns only that prefix.

Accent-mark removal does not transliterate every writing system. The normalized part is at most 50 ASCII bytes; Generate can return 59 bytes including its hyphen and UUID prefix. Eight UUID characters are not a uniqueness guarantee; the application owns collision handling and stable identifiers.