twenty / packages /twenty-shared /src /utils /url /normalizeUrl.ts
Jules
Initial clean CRM deployment with prebuilt assets
d9494a5
Raw
History Blame Contribute Delete
420 Bytes
import { ensureAbsoluteUrl } from '@/utils/url/ensureAbsoluteUrl';
import { normalizeUrlOrigin } from '@/utils/url/normalizeUrlOrigin';
// Ensures the URL has a protocol, lowercases the origin, and removes a trailing slash.
export const normalizeUrl = (url: string): string => {
const trimmed = url.trim();
if (trimmed === '') {
return trimmed;
}
return normalizeUrlOrigin(ensureAbsoluteUrl(trimmed));
};