Fix link formatting (#13210)

closes https://github.com/twentyhq/twenty/issues/13207

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
This commit is contained in:
Paul Rastoin
2025-07-15 12:27:00 +02:00
committed by GitHub
parent eed502778a
commit d916ec0af9
12 changed files with 87 additions and 60 deletions

View File

@ -0,0 +1,15 @@
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(/\/$/, '');
};