Skip to main content
Glama
formatOnboardUrl.ts1.35 kB
import { PagesRoutes } from '@/Routes'; import { Period, Plans } from '../PricingPage/data.content'; import { Steps } from './steps'; type Args = { plan?: Plans; step?: Steps; period?: Period; origin?: string; otherParams?: Record<string, string>; }; export const formatOnboardUrl = ({ plan = Plans.Free, step = Steps.Registration, period = Period.Monthly, origin = typeof window !== 'undefined' ? window.location.href : '', otherParams = {}, }: Args = {}) => { // Start building the URL manually let url = PagesRoutes.Onboarding_Flow.replace('{{step}}', step!).replace( '{{plan}}', plan! ); if (period) { url = url.replace('{{period}}', period!); } else { url = url.replace('{{period}}/', ''); } // Create an array to hold query parameter strings const queryParams: string[] = []; // Add the origin if available if (origin) { queryParams.push(`origin=${encodeURIComponent(origin)}`); } // Loop through the additional params and add them for (const key in otherParams) { if (Object.hasOwn(otherParams, key)) { queryParams.push( `${encodeURIComponent(key)}=${encodeURIComponent(otherParams[key])}` ); } } // Append query parameters to the URL if any exist if (queryParams.length > 0) { url += `?${queryParams.join('&')}`; } return url; };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/aymericzip/intlayer'

If you have feedback or need assistance with the MCP directory API, please join our Discord server