fix: handle cdnPrefix without protocol (#5373)
* fix: handle cdnPrefix without protocol * cdnPrefix trim
This commit is contained in:
parent
e295cbbcc6
commit
7c0a2692dc
|
@ -24,9 +24,10 @@ export const formatAttachmentUrl = (attachmentUrl: string | undefined, userId: s
|
||||||
}
|
}
|
||||||
return setParamInUrl({ url: attachmentUrl, token, userId });
|
return setParamInUrl({ url: attachmentUrl, token, userId });
|
||||||
}
|
}
|
||||||
const cdnPrefix = store?.getState().settings.CDN_PREFIX as string;
|
let cdnPrefix = store?.getState().settings.CDN_PREFIX as string;
|
||||||
if (cdnPrefix) {
|
cdnPrefix = cdnPrefix?.trim();
|
||||||
server = cdnPrefix.trim().replace(/\/+$/, '');
|
if (cdnPrefix && cdnPrefix.startsWith('http')) {
|
||||||
|
server = cdnPrefix.replace(/\/+$/, '');
|
||||||
}
|
}
|
||||||
return setParamInUrl({ url: `${server}${attachmentUrl}`, token, userId });
|
return setParamInUrl({ url: `${server}${attachmentUrl}`, token, userId });
|
||||||
};
|
};
|
||||||
|
|
|
@ -49,8 +49,9 @@ export const getAvatarURL = ({
|
||||||
query += `&etag=${avatarETag}`;
|
query += `&etag=${avatarETag}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cdnPrefix) {
|
cdnPrefix = cdnPrefix?.trim();
|
||||||
server = cdnPrefix.trim().replace(/\/+$/, '');
|
if (cdnPrefix && cdnPrefix.startsWith('http')) {
|
||||||
|
server = cdnPrefix.replace(/\/+$/, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (avatar) {
|
if (avatar) {
|
||||||
|
|
Loading…
Reference in New Issue