Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1215 from Shopify/ps/fix-store-hosts-starting-wit…
Browse files Browse the repository at this point in the history
…h-http

Fix validations for store hosts starting with http
  • Loading branch information
paulspringett authored Feb 14, 2024
2 parents 71bda29 + 295859d commit 120a394
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/curly-boxes-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@shopify/graphql-client": patch
---

Fix GraphQL client validations for store hosts starting with http
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,26 @@ describe("validateDomainAndGetStoreUrl())", () => {
});
expect(domain).toEqual(`https://${domainOnly}`);
});

it("returns a store url when a protocol-less store domain starting with http is provided", () => {
const domainOnly = "http-test-store.myshopify.io";

const domain = validateDomainAndGetStoreUrl({
client,
storeDomain: domainOnly,
});
expect(domain).toEqual(`https://${domainOnly}`);
});

it("returns a store url when a protocol-less store domain starting with https is provided", () => {
const domainOnly = "https-test-store.myshopify.io";

const domain = validateDomainAndGetStoreUrl({
client,
storeDomain: domainOnly,
});
expect(domain).toEqual(`https://${domainOnly}`);
});
});

describe("validateRequiredApiVersion()", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ export function validateDomainAndGetStoreUrl({

const trimmedDomain = storeDomain.trim();

const protocolUrl = trimmedDomain.startsWith("http")
? trimmedDomain
: `https://${trimmedDomain}`;
const protocolUrl =
trimmedDomain.startsWith("http:") || trimmedDomain.startsWith("https:")
? trimmedDomain
: `https://${trimmedDomain}`;

const url = new URL(protocolUrl);
url.protocol = "https";
Expand Down

0 comments on commit 120a394

Please sign in to comment.