UNPKG

@godaddy/react

Version:

The `createCheckoutSession` function creates a new checkout session with GoDaddy's commerce API.

41 lines (39 loc) • 1.17 kB
import { clsx } from "clsx"; import { twMerge } from "tailwind-merge"; //#region src/lib/utils.ts function cn(...inputs) { return twMerge(clsx(inputs)); } function getUrlHash(location) { return location.hash.replace(/^#/, ""); } function getSessionIdFromPath(location) { const segments = location.pathname.split("/").filter(Boolean); return segments[segments.length - 1]; } /** * Get an environment variable with framework-specific prefix detection. * Checks for Next.js (NEXT_PUBLIC_), Vite (VITE_), and unprefixed variables. * * @param key - The environment variable name without framework prefix * @returns The environment variable value or empty string if not found * * @example * ```ts * // Automatically checks NEXT_PUBLIC_STRIPE_KEY, VITE_STRIPE_KEY, and STRIPE_KEY * const stripeKey = getEnvVar('STRIPE_KEY'); * ``` */ function getEnvVar(key) { for (const prefix of [ "NEXT_PUBLIC_", "VITE_", "" ]) if (typeof process !== "undefined" && process.env) { const value = process.env[`${prefix}${key}`]; if (value !== void 0) return value; } return ""; } //#endregion export { getUrlHash as i, getEnvVar as n, getSessionIdFromPath as r, cn as t };