import { API_HOSTS, ApiHost } from './api-host';

export function buildApiUrl(
  host: ApiHost,
  endpoint: string
): string {
  const baseUrl = API_HOSTS[host].replace(/\/+$/, '');
  const normalizedEndpoint = endpoint.startsWith('/')
    ? endpoint
    : `/${endpoint}`;

  return `${baseUrl}${normalizedEndpoint}`;
}