This commit is contained in:
砂糖
2026-01-24 16:54:44 +08:00
commit 70f337bb92
186 changed files with 23792 additions and 0 deletions

19
lib/utils.ts Normal file
View File

@@ -0,0 +1,19 @@
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;
}
};