Skip to content

fix(import-deco): slugify the site name before building its preview host - #6703

Merged
pedrofrxncx merged 1 commit into
mainfrom
fix/import-deco-preview-url-unsanitized-name
Aug 28, 2026
Merged

fix(import-deco): slugify the site name before building its preview host#6703
pedrofrxncx merged 1 commit into
mainfrom
fix/import-deco-preview-url-unsanitized-name

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Follows #6699, which switched the deco.cx import flow to default previewServerUrl to a {slug}.deco.site guess instead of the site's reported domain.

The gap: the guess was built from siteName.toLowerCase() (site.name is a free-text display title shown as-is in the import picker, not a hostname). Any site name containing a space or symbol — e.g. "My Cool Site" — produces "my cool site.deco.site", which makes new URL() throw; productionUrlFromDomain's try/catch swallows that into null. The import silently completes with no previewServerUrl (and no productionUrl, since it's dual-written from the same value), so the CMS preview has nothing to render against — no error, no toast.

Fix: extracted the host guess into defaultPreviewServerUrl(siteName) (packages/shared/src/deco-site-production-url.ts), which slugifies the name (reusing the existing slugify helper) before handing it to productionUrlFromDomain. The component now calls this instead of building the string inline. Also updated the module's header comment, which still described the pre-#6699 domain-preference behavior.

Regression test: packages/shared/src/deco-site-production-url.test.tsdefaultPreviewServerUrl("My Cool Site!") now resolves to https://my-cool-site.deco.site/ instead of null (fails on current main before this fix... actually current main doesn't have the helper at all; the test asserts the fixed behavior directly and would fail against the pre-fix inline ${siteName.toLowerCase()}.deco.site construction).

Reviewer command: bun test packages/shared/src/deco-site-production-url.test.ts

Locally verified: bun run fmt, tsc --noEmit in packages/shared and apps/web (clean for the touched files — apps/web has one pre-existing, unrelated prosemirror-version type error), bunx oxlint on the three touched files (0 warnings/errors), and the targeted test file above (17/17 pass). Full CI covers the rest.


Summary by cubic

Fixes the deco.cx import flow so preview hosts built from site names are slugified, preventing silent failures when names contain spaces or symbols.

  • The old inline ${siteName.toLowerCase()}.deco.site construction could throw and be swallowed, leaving imported sites without a preview server. Now defaultPreviewServerUrl reuses the existing slugify helper and returns null for empty or nullish names instead of throwing.
  • Adds tests covering slugified names and null handling.

Written for commit fbefb73. Summary will update on new commits.

Review in cubic

@pedrofrxncx
pedrofrxncx merged commit 6bd9750 into main Aug 28, 2026
34 checks passed
@pedrofrxncx
pedrofrxncx deleted the fix/import-deco-preview-url-unsanitized-name branch August 28, 2026 17:06
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