Fix broken image urls in Settings > Profile and Invite To Workspace Email (#8942)
Fixes #8601 We had 3 implementations of getImageAbsoluteURI: in twenty-front, in twenty-ui and in twenty-emails. I was able to remove the one in twenty-front but I could not remove it from twenty-emails as this is a standalone for now. The vision is to introduce shared utils in a twenty-shared package
This commit is contained in:
@ -1,16 +1,9 @@
|
||||
export const getImageAbsoluteURI = (
|
||||
imageUrl?: string | null,
|
||||
serverUrl?: string,
|
||||
) => {
|
||||
if (!imageUrl) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (imageUrl?.startsWith('https:')) {
|
||||
export const getImageAbsoluteURI = (imageUrl: string, serverUrl: string) => {
|
||||
if (imageUrl.startsWith('https:') || imageUrl.startsWith('http:')) {
|
||||
return imageUrl;
|
||||
}
|
||||
|
||||
return serverUrl?.endsWith('/')
|
||||
return serverUrl.endsWith('/')
|
||||
? `${serverUrl.substring(0, serverUrl.length - 1)}/files/${imageUrl}`
|
||||
: `${serverUrl || ''}/files/${imageUrl}`;
|
||||
: `${serverUrl}/files/${imageUrl}`;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user