diff --git a/.changeset/normalize-store-fqdn-suffix.md b/.changeset/normalize-store-fqdn-suffix.md new file mode 100644 index 00000000000..2bb271fb98e --- /dev/null +++ b/.changeset/normalize-store-fqdn-suffix.md @@ -0,0 +1,5 @@ +--- +'@shopify/cli-kit': patch +--- + +Only treat `.myshopify.io` (not any `shopify.io` suffix) as an already-normalized store FQDN diff --git a/packages/cli-kit/src/public/node/context/fqdn.test.ts b/packages/cli-kit/src/public/node/context/fqdn.test.ts index 72f51b35dda..77969053eaf 100644 --- a/packages/cli-kit/src/public/node/context/fqdn.test.ts +++ b/packages/cli-kit/src/public/node/context/fqdn.test.ts @@ -217,4 +217,37 @@ describe('normalizeStore', () => { // Then expect(got).toEqual('example.myshopify.com') }) + + test('preserves local dev store names ending in .myshopify.io', async () => { + // Given + vi.mocked(serviceEnvironment).mockReturnValue(Environment.Local) + + // When + const got = normalizeStoreFqdn('example.myshopify.io') + + // Then + expect(got).toEqual('example.myshopify.io') + }) + + test('does not treat other domains ending in shopify.io as already normalized', async () => { + // Given + vi.mocked(serviceEnvironment).mockReturnValue(Environment.Production) + + // When + const got = normalizeStoreFqdn('exampleshopify.io') + + // Then + expect(got).toEqual('exampleshopify.io.myshopify.com') + }) + + test('does not treat nested domains ending in shopify.io as already normalized', async () => { + // Given + vi.mocked(serviceEnvironment).mockReturnValue(Environment.Production) + + // When + const got = normalizeStoreFqdn('example.exampleshopify.io') + + // Then + expect(got).toEqual('example.exampleshopify.io.myshopify.com') + }) }) diff --git a/packages/cli-kit/src/public/node/context/fqdn.ts b/packages/cli-kit/src/public/node/context/fqdn.ts index 85e6036bb1f..4bbe1592cf4 100644 --- a/packages/cli-kit/src/public/node/context/fqdn.ts +++ b/packages/cli-kit/src/public/node/context/fqdn.ts @@ -139,7 +139,7 @@ export function normalizeStoreFqdn(store: string): string { } } const containDomain = (storeFqdn: string) => - storeFqdn.endsWith('.myshopify.com') || storeFqdn.endsWith('shopify.io') || storeFqdn.endsWith('.shop.dev') + storeFqdn.endsWith('.myshopify.com') || storeFqdn.endsWith('.myshopify.io') || storeFqdn.endsWith('.shop.dev') return containDomain(storeFqdn) ? storeFqdn : addDomain(storeFqdn) }