The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/packages/rocketchat-ui/getAvatarUrlFromUsername.js

17 lines
665 B

// TODO: remove global
this.getAvatarUrlFromUsername = function(username) {
const key = `avatar_random_${ username }`;
const random = typeof Session !== 'undefined' ? Session.keys[key] : 0;
if (username == null) {
return;
}
const cdnPrefix = (RocketChat.settings.get('CDN_PREFIX') || '').trim().replace(/\/$/, '');
const pathPrefix = (__meteor_runtime_config__.ROOT_URL_PATH_PREFIX || '').trim().replace(/\/$/, '');
let path = pathPrefix;
if (cdnPrefix) {
path = cdnPrefix + pathPrefix;
} else if (Meteor.isCordova) {
path = Meteor.absoluteUrl().replace(/\/$/, '');
}
return `${ path }/avatar/${ encodeURIComponent(username) }?_dc=${ random }`;
};