closes https://github.com/twentyhq/twenty/issues/13207 --------- Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
16 lines
429 B
TypeScript
16 lines
429 B
TypeScript
import { getURLSafely } from '@/utils/getURLSafely';
|
|
import { isDefined } from '@/utils/validation';
|
|
|
|
export const lowercaseUrlOriginAndRemoveTrailingSlash = (rawUrl: string) => {
|
|
const url = getURLSafely(rawUrl);
|
|
|
|
if (!isDefined(url)) {
|
|
return rawUrl;
|
|
}
|
|
|
|
const lowercaseOrigin = url.origin.toLowerCase();
|
|
const path = url.pathname + url.search + url.hash;
|
|
|
|
return (lowercaseOrigin + path).replace(/\/$/, '');
|
|
};
|