mirror of
https://github.com/vercel/commerce.git
synced 2025-05-15 05:56:59 +00:00
No hidden undefined
This commit is contained in:
parent
2c87e1b769
commit
f332d0ff85
@ -8,8 +8,8 @@ const { TWITTER_CREATOR, TWITTER_SITE, SITE_NAME } = process.env;
|
||||
const baseUrl = process.env.NEXT_PUBLIC_VERCEL_URL
|
||||
? `https://${process.env.NEXT_PUBLIC_VERCEL_URL}`
|
||||
: 'http://localhost:3000';
|
||||
const twitterCreator = ensureStartsWith(TWITTER_CREATOR, '@');
|
||||
const twitterSite = ensureStartsWith(TWITTER_SITE, 'https://');
|
||||
const twitterCreator = TWITTER_CREATOR ? ensureStartsWith(TWITTER_CREATOR, '@') : undefined;
|
||||
const twitterSite = TWITTER_SITE ? ensureStartsWith(TWITTER_SITE, 'https://') : undefined;
|
||||
|
||||
export const metadata = {
|
||||
metadataBase: new URL(baseUrl),
|
||||
|
@ -50,7 +50,9 @@ import {
|
||||
ShopifyUpdateCartOperation
|
||||
} from './types';
|
||||
|
||||
const domain = ensureStartsWith(process.env.SHOPIFY_STORE_DOMAIN, 'https://') || '';
|
||||
const domain = process.env.SHOPIFY_STORE_DOMAIN
|
||||
? ensureStartsWith(process.env.SHOPIFY_STORE_DOMAIN, 'https://')
|
||||
: '';
|
||||
const endpoint = `${domain}${SHOPIFY_GRAPHQL_API_ENDPOINT}`;
|
||||
const key = process.env.SHOPIFY_STOREFRONT_ACCESS_TOKEN!;
|
||||
|
||||
|
@ -7,8 +7,5 @@ export const createUrl = (pathname: string, params: URLSearchParams | ReadonlyUR
|
||||
return `${pathname}${queryString}`;
|
||||
};
|
||||
|
||||
export const ensureStartsWith = (stringToCheck?: string, startsWith?: string) => {
|
||||
if (!stringToCheck || !startsWith) return stringToCheck;
|
||||
|
||||
return stringToCheck.startsWith(startsWith) ? stringToCheck : `${startsWith}${stringToCheck}`;
|
||||
};
|
||||
export const ensureStartsWith = (stringToCheck: string, startsWith: string) =>
|
||||
stringToCheck.startsWith(startsWith) ? stringToCheck : `${startsWith}${stringToCheck}`;
|
||||
|
Loading…
x
Reference in New Issue
Block a user