URL slugs: turning a human title into an address.
Pure and dependency-free so anything can use it. Nothing in the repo did this before — market taxonomy slugs (game.protocols.market) are caller-supplied strings, validated as non-empty and never normalized, which is why a category can be registered as "Merch " and a post could not have a slug at all.
URL slugs: turning a human title into an address. Pure and dependency-free so anything can use it. Nothing in the repo did this before — market taxonomy slugs (game.protocols.market) are caller-supplied strings, validated as non-empty and never normalized, which is why a category can be registered as "Merch " and a post could not have a slug at all.
(disambiguate base taken?)base, or the first of base-2, base-3 … that taken? rejects.
taken? is any predicate — a set of existing slugs is the usual caller.
Suffixes start at 2, not 1: the first duplicate is the second post, and -1
would imply the original is -0.
nil base returns nil. There is nothing to disambiguate, and inventing "-2" for an absent slug would hide the caller's fallback.
`base`, or the first of base-2, base-3 … that `taken?` rejects. `taken?` is any predicate — a set of existing slugs is the usual caller. Suffixes start at 2, not 1: the first duplicate is the second post, and -1 would imply the original is -0. nil base returns nil. There is nothing to disambiguate, and inventing "-2" for an absent slug would hide the caller's fallback.
(slugify title)A URL-safe slug for title, or nil when nothing usable survives.
nil rather than "" is the important part: an empty slug produces the URL /essays/ for every such post — a silent collision rather than a visible failure. Callers must handle nil, typically by falling back to an id.
Diacritics are folded (ü → u) rather than stripped, because dropping them turns 'über' into 'ber', a different word. A title with no latin characters at all yields nil, which is honest: there is nothing here to romanize, and guessing would be worse than falling back.
A URL-safe slug for `title`, or nil when nothing usable survives. nil rather than "" is the important part: an empty slug produces the URL /essays/ for every such post — a silent collision rather than a visible failure. Callers must handle nil, typically by falling back to an id. Diacritics are folded (ü → u) rather than stripped, because dropping them turns 'über' into 'ber', a different word. A title with no latin characters at all yields nil, which is honest: there is nothing here to romanize, and guessing would be worse than falling back.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |