RocketChat/Rocket.Chat

View on GitHub
apps/meteor/app/utils/client/getAvatarURL.ts

Summary

Maintainability
B
6 hrs
Test Coverage
import { getURL } from './getURL';

export const getAvatarURL = ({ username, roomId, cache }: { username?: string; roomId?: string; cache?: string }): string | undefined => {
    if (username) {
        return getURL(`/avatar/${encodeURIComponent(username)}${cache ? `?etag=${cache}` : ''}`);
    }
    if (roomId) {
        return getURL(`/avatar/room/${encodeURIComponent(roomId)}${cache ? `?etag=${cache}` : ''}`);
    }
};