Files
fad-trade-next/lib/utils.ts

19 lines
567 B
TypeScript
Raw Permalink Normal View History

2025-11-21 13:36:06 +08:00
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
export const getDomain = (url: string) => {
try {
// Add https:// protocol if not present
const urlWithProtocol = url.startsWith('http') ? url : `https://${url}`;
const domain = new URL(urlWithProtocol).hostname;
// Remove 'www.' prefix if exists
return domain.replace(/^www\./, '');
} catch (error) {
// Return original input if URL parsing fails
return url;
}
};