Skip to content

Commit

Permalink
re-use storeName
Browse files Browse the repository at this point in the history
  • Loading branch information
tlgimenes committed Sep 1, 2023
1 parent c2616ec commit 21b7e91
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
19 changes: 7 additions & 12 deletions shopify/loaders/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,17 @@ const PATHS_TO_PROXY = [
const decoSiteMapUrl = "/sitemap/deco.xml";

const buildProxyRoutes = (
{ publicUrl, extraPaths, includeSiteMap, generateDecoSiteMap }: {
publicUrl?: string;
{ storeName, extraPaths, includeSiteMap, generateDecoSiteMap }: {
storeName?: string;
extraPaths: string[];
includeSiteMap?: string[];
generateDecoSiteMap?: boolean;
},
) => {

if (!publicUrl) {
return [];
}
const publicUrl = new URL(`https://${storeName}.myshopify.com`);

try {
const hostname = (new URL(
publicUrl?.startsWith("http") ? publicUrl : `https://${publicUrl}`,
)).hostname;
const hostname = publicUrl.hostname;

// Rejects TLD mystore.com, keep this if Shopify doesn't support
if (!hostname || hostname.split(".").length <= 2) {
Expand All @@ -55,7 +50,7 @@ const buildProxyRoutes = (
routeFromPath,
);

const [include, routes] = generateDecoSiteMap
const [_include, routes] = generateDecoSiteMap
? [[...(includeSiteMap ?? []), decoSiteMapUrl], [{
pathTemplate: decoSiteMapUrl,
handler: {
Expand All @@ -65,7 +60,7 @@ const buildProxyRoutes = (
},
}]]
: [includeSiteMap, []];

return [
...routes,
...routesFromPaths,
Expand Down Expand Up @@ -101,7 +96,7 @@ function loader(
return buildProxyRoutes({
generateDecoSiteMap,
includeSiteMap,
publicUrl: ctx.publicUrl,
storeName: ctx.storeName,
extraPaths: extraPathsToProxy,
});
}
Expand Down
5 changes: 0 additions & 5 deletions shopify/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ export interface Props {
*/
storeName: string;

/**
* @description Store public URL.
*/
publicUrl: string;

/**
* @ttile Access Token
* @description Shopify storefront access token.
Expand Down

0 comments on commit 21b7e91

Please sign in to comment.