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 });
|
||||
}
|
||||
const cdnPrefix = store?.getState().settings.CDN_PREFIX as string;
|
||||
if (cdnPrefix) {
|
||||
server = cdnPrefix.trim().replace(/\/+$/, '');
|
||||
let cdnPrefix = store?.getState().settings.CDN_PREFIX as string;
|
||||
cdnPrefix = cdnPrefix?.trim();
|
||||
if (cdnPrefix && cdnPrefix.startsWith('http')) {
|
||||
server = cdnPrefix.replace(/\/+$/, '');
|
||||
}
|
||||
return setParamInUrl({ url: `${server}${attachmentUrl}`, token, userId });
|
||||
};
|
||||
|
|
|
@ -49,8 +49,9 @@ export const getAvatarURL = ({
|
|||
query += `&etag=${avatarETag}`;
|
||||
}
|
||||
|
||||
if (cdnPrefix) {
|
||||
server = cdnPrefix.trim().replace(/\/+$/, '');
|
||||
cdnPrefix = cdnPrefix?.trim();
|
||||
if (cdnPrefix && cdnPrefix.startsWith('http')) {
|
||||
server = cdnPrefix.replace(/\/+$/, '');
|
||||
}
|
||||
|
||||
if (avatar) {
|
||||
|
|
Loading…
Reference in New Issue