28202cc9e0
## Fixes wrong image url in email  ## Done - duplicates and adapt `getImageAbsoluteURIOrBase64` from `twenty-front` in `twenty-email` - send `SERVER_URL` to email builder
17 lines
399 B
TypeScript
17 lines
399 B
TypeScript
export const getImageAbsoluteURIOrBase64 = (
|
|
imageUrl?: string | null,
|
|
serverUrl?: string,
|
|
) => {
|
|
if (!imageUrl) {
|
|
return null;
|
|
}
|
|
|
|
if (imageUrl?.startsWith('data:') || imageUrl?.startsWith('https:')) {
|
|
return imageUrl;
|
|
}
|
|
|
|
return serverUrl?.endsWith('/')
|
|
? `${serverUrl.substring(0, serverUrl.length - 1)}/files/${imageUrl}`
|
|
: `${serverUrl || ''}/files/${imageUrl}`;
|
|
};
|