refactor(domain): resolve every locale into one domain shape at build time - #4093
Conversation
…time `normalizeDomainLocale` now always sets `domains` and `defaultForDomains`, so domain logic can read them without a fallback, and the result is typed as `NormalizedLocaleObject`. `domainDefault` is fully resolved into `defaultForDomains`, so the type takes it away - reading it past normalization is how the build and the runtime came to disagree in #4090. The test helpers resolve their locales through the normalizer the same way `resolveContext` does, rather than passing a shape the build never produces.
Domain resolution reads the array fields directly rather than falling back between the two shapes. Behavior is unchanged, `domainFromLocale` still prefers a locale's own `domain` and a host matching no configured domain still resolves none, so dev and staging keep relative URLs. `composer.localeProperties` falls back to a bare locale when the current one is not configured, which is now built in the normalized shape.
37f3242 to
552e5dc
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (19)
WalkthroughThe change introduces Estimated code review effort: 4 (Complex) | ~45 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The domain bugs fixed in #4090 came from the same place:
domain/domainDefaultanddomains/defaultForDomainsdescribe the same thing, and the build and the runtime each picked which pair to read.normalizeDomainLocalewas meant to settle that but only resolved part of it, so a locale could reach route generation or link resolution with either shape missing.It's now total,
domainsanddefaultForDomainsare always set, and the result is typed asNormalizedLocaleObject. Domain logic reads the array fields without falling back, anddomainDefaultis dropped from that type since it resolves fully intodefaultForDomains- reading it past normalization is how the two sides came to disagree.domainis kept, it additionally marks the locale's own domain anddomainscan't express that.Behavior is unchanged.
domainFromLocalestill prefers a locale's owndomain, and a host matching no configured domain still resolves none, so dev and staging keep relative URLs.The type is applied where locales reach domain logic: the resolved context, the runtime config channel and
localizeRoutes. The test helpers resolve their locales through the normalizer the wayresolveContextdoes, rather than passing a shape the build never produces.Summary by CodeRabbit