Skip to content

fix(assets-tab): slugify the project title before matching a bucket - #6318

Open
pedrofrxncx wants to merge 1 commit into
mainfrom
fix/slugify-site-name-before-bucket-match-w4
Open

fix(assets-tab): slugify the project title before matching a bucket#6318
pedrofrxncx wants to merge 1 commit into
mainfrom
fix/slugify-site-name-before-bucket-match-w4

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Source

Follows #6296 ("gate assets tab on project name, not metadata.siteSlug"), which switched matchSiteSlugConfig's callers from entity.metadata.siteSlug to entity.title. That PR's own description flagged the gap it left open:

title is a free-form display name while the match target is a strict lowercase slug (deco-assets-<slug>). A project titled "Deco CMS" won't match decocms. Fine if projects import with the exact slug as the title; if titles can diverge we'd slugify the title before comparing.

Why a maintainer wants this

Any project whose display title isn't already a bare slug (has a space, capital letter, or punctuation) silently loses its Assets tab even though the matching bucket exists — a real regression class for any non-imported or renamed project, not just deco.cx imports.

The fix

matchSiteSlugConfig now runs its input through the existing @decocms/shared slugify() (no new dependency, no hand-rolled normalization) before comparing against config.siteSlug/config.bucket. This is a no-op for inputs that were already slugs, so both existing call sites (use-main-panel-tabs.ts, assets-tab.tsx) keep behaving exactly as before for the common case, and now also match titles like "Deco CMS" against a deco-assets-deco-cms bucket.

Added two test cases: a free-form title matching its slugified bucket, and an all-punctuation title slugifying to empty (still returns null, same as an empty string).

Verify

bun test apps/web/src/components/file-picker/match-site-slug-config.test.ts

Checks run locally

  • bun run fmt — clean
  • cd apps/web && bunx tsc --noEmit — clean
  • bunx oxlint on both changed files — 0 warnings/errors
  • Targeted test file above — 9/9 pass

Full CI validates the rest.


Summary by cubic

Slugifies project titles before matching an Assets bucket so titles with spaces or punctuation still match. Previously we only lowercased titles and missed matches; now we use slugify() and return null if the slug is empty. Inputs already in slug form behave the same.

  • Review notes
    • Uses slugify from @decocms/shared/utils/slugify; no new dependency.
    • Change is limited to matchSiteSlugConfig; call sites and common cases remain unchanged.
    • Adds tests for a free-form title matching its slugified bucket and for an all-punctuation title returning null.

Written for commit 1db6d7a. Summary will update on new commits.

Review in cubic

#6296 switched the Assets tab's bucket match from metadata.siteSlug to
entity.title (a free-form display name), and its own description called out
the gap: a title like "Deco CMS" won't match a deco-assets-decocms bucket
because matchSiteSlugConfig only lowercases, it doesn't slugify.

Reuse the existing @decocms/shared slugify() (no new dependency) inside
matchSiteSlugConfig so any caller passing a display name gets the same
matching a slug would. No-op for values that were already slugs, so both
existing call sites (use-main-panel-tabs.ts, assets-tab.tsx) keep working
unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant