-
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathutils.ts
More file actions
21 lines (18 loc) · 692 Bytes
/
utils.ts
File metadata and controls
21 lines (18 loc) · 692 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
export type ObjectValues<T> = T[keyof T];
/**
* Join a path with the base URL, ensuring proper slashes
* Handles cases where BASE_URL may or may not end with /
*/
export function baseUrl(path: string): string {
const base = import.meta.env.BASE_URL;
// Remove leading slash from path if present
const cleanPath = path.startsWith('/') ? path.slice(1) : path;
// Ensure base ends with /, then concatenate
const baseWithSlash = base.endsWith('/') ? base : `${base}/`;
return `${baseWithSlash}${cleanPath}`;
}