feat: add links to Links field (#5223)
Closes #5115, Closes #5116 <img width="242" alt="image" src="https://github.com/twentyhq/twenty/assets/3098428/ab78495a-4216-4243-8de3-53720818a09b"> --------- Co-authored-by: Jérémy Magrin <jeremy.magrin@gmail.com>
This commit is contained in:
9
packages/twenty-front/src/utils/url/getAbsoluteUrl.ts
Normal file
9
packages/twenty-front/src/utils/url/getAbsoluteUrl.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { absoluteUrlSchema } from '~/utils/validation-schemas/absoluteUrlSchema';
|
||||
|
||||
export const getAbsoluteUrl = (url: string) => {
|
||||
try {
|
||||
return absoluteUrlSchema.parse(url);
|
||||
} catch {
|
||||
return '';
|
||||
}
|
||||
};
|
||||
@ -1,8 +1,8 @@
|
||||
import { absoluteUrlSchema } from '~/utils/validation-schemas/absoluteUrlSchema';
|
||||
import { getAbsoluteUrl } from '~/utils/url/getAbsoluteUrl';
|
||||
|
||||
export const getUrlHostName = (url: string) => {
|
||||
try {
|
||||
const absoluteUrl = absoluteUrlSchema.parse(url);
|
||||
const absoluteUrl = getAbsoluteUrl(url);
|
||||
return new URL(absoluteUrl).hostname.replace(/^www\./i, '');
|
||||
} catch {
|
||||
return '';
|
||||
|
||||
Reference in New Issue
Block a user