fix: dynamically resolve localhost/127.0.0.1 in links to active hostname for remote access
This commit is contained in:
@@ -4,3 +4,12 @@ import { twMerge } from "tailwind-merge"
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs))
|
||||
}
|
||||
|
||||
export function resolveExternalUrl(url?: string): string {
|
||||
if (!url) return ""
|
||||
const currentHostname = window.location.hostname
|
||||
if (currentHostname !== "127.0.0.1" && currentHostname !== "localhost" && currentHostname !== "") {
|
||||
return url.replace(/127\.0\.0\.1|localhost/g, currentHostname)
|
||||
}
|
||||
return url
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user