Repository navigation
Agree on how EmDash stores the slugs people and clients type #4359
Replies: 1 comment 2 replies
|
The use case is genuine and I understand why something like this is useful, but my issue is how opinionated it is. It formats spacing in a specific way, and it's not just a simple trim. Special characters are also percent encoded, should those be excluded too? What about Latin accents, or Arabic, Russian, Chinese characters, etc. Where do you draw the line? A better approach IMO is the ability to enforce a slug pattern with RegEx. So you could have something like kebab case as the default (which is what I assume you are going for) while allowing site owners to customize it if they need to. If an editor tries to save without satisfying the pattern, the save should be rejected (similar to what we do with fields). That way they could notice their mistake and correct it. As for formatting, I think this should be left to plugins. Both formatting before save (i.e. changing the slug the user already typed) or slugifying a title (which is a feature we don't have yet). What do you think? |
Uh oh!
There was an error while loading. Please reload this page.
Problem
EmDash stores an entry slug exactly as it receives it. Slugs generated from a title go through
slugify, but a slug typed in the admin's Slug field or sent through the REST API or MCP is not trimmed, normalized or validated. A post recently went live at a URL ending in%20%20/because two trailing spaces were typed into its Slug field.EmDash has no agreed contract for what a stored slug may contain. #4350 implements one answer, and before it ships the questions below need agreement.
What #4350 does
" my post "and"my - post"both becomemy-post. Case, dots and underscores are kept."my post"gets"my-post"back and has to look the entry up by that. A cleaned slug can also collide with an existing one and returnSLUG_CONFLICT.Questions to agree on
slugifyrules (lowercase, drop unsafe characters) to typed slugs too.Use case
Editors type or paste slugs in the admin. Trailing spaces don't show in the Slug field, so a broken URL is only noticed after publishing, by which time it has been shared. API and MCP clients, including AI agents, also set slugs directly. Site code and integrations look entries up by slug, so the contract decides whether a caller can rely on getting back the slug it sent.
Current workarounds
Check the public URL after publishing. To fix a broken one, retype the entry's slug and publish the change; EmDash then redirects the old URL to the new one.
Your involvement
All reactions