fix(import-deco): slugify the site name before building its preview host - #6703
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follows #6699, which switched the deco.cx import flow to default
previewServerUrlto a{slug}.deco.siteguess instead of the site's reported domain.The gap: the guess was built from
siteName.toLowerCase()(site.nameis 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 makesnew URL()throw;productionUrlFromDomain'stry/catchswallows that intonull. The import silently completes with nopreviewServerUrl(and noproductionUrl, 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 existingslugifyhelper) before handing it toproductionUrlFromDomain. 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.ts—defaultPreviewServerUrl("My Cool Site!")now resolves tohttps://my-cool-site.deco.site/instead ofnull(fails on currentmainbefore 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.siteconstruction).Reviewer command:
bun test packages/shared/src/deco-site-production-url.test.tsLocally verified:
bun run fmt,tsc --noEmitinpackages/sharedandapps/web(clean for the touched files — apps/web has one pre-existing, unrelated prosemirror-version type error),bunx oxlinton 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.
${siteName.toLowerCase()}.deco.siteconstruction could throw and be swallowed, leaving imported sites without a preview server. NowdefaultPreviewServerUrlreuses the existingslugifyhelper and returnsnullfor empty or nullish names instead of throwing.Written for commit fbefb73. Summary will update on new commits.