ref(ui): Extract pure normalizeUrlWithCustomerDomain, keep normalizeUrl wrapper#119371
Closed
ryan953 wants to merge 1 commit into
Closed
ref(ui): Extract pure normalizeUrlWithCustomerDomain, keep normalizeUrl wrapper#119371ryan953 wants to merge 1 commit into
ryan953 wants to merge 1 commit into
Conversation
f16a5e9 to
745f4c8
Compare
…rl wrapper
Split normalizeUrl into a pure core and a thin wrapper:
- normalizeUrlWithCustomerDomain(path, {customerDomain, force}) is pure. It
takes the customer domain as an argument instead of reading global config,
making it easy to test and reuse for a domain other than the active one.
- normalizeUrl(path, {forceCustomerDomain}) keeps its exact public API and now
delegates to the pure function, injecting ConfigStore.get('customerDomain').
Every existing callsite is unchanged. No behavior change.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
745f4c8 to
95b3d8f
Compare
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.
Summary
Splits
normalizeUrlinto a pure core plus a thin wrapper, so the customer-domain lookup is decoupled from the global config store without churning every callsite.normalizeUrlWithCustomerDomain(path, {customerDomain, force})— pure. Takes the customer domain as an argument instead of readingConfigStore, so it's trivially testable and reusable (e.g. normalizing for a domain other than the active one).normalizeUrl(path, {forceCustomerDomain})— unchanged public API. Now delegates to the pure function, injectingConfigStore.get('customerDomain').Why this shape
An earlier revision of this PR pushed
ConfigStore.get('customerDomain')out to all ~240 callsites. That worked but was a huge, noisy diff. The wrapper keeps the ergonomicnormalizeUrl(path)API every callsite already uses while still exposing a pure function for callers that want to supply the domain themselves.Scope
Every existing callsite is unchanged. The diff is two files: the util and its spec. No behavior change — the wrapper reproduces the original
force-or-active-domaingate exactly.Verification
pnpm typecheck— green (0 errors), confirming all existing callsites still compile against the wrapperConfigStore+ pure-function behavior (including that the pure fn ignores global config)