/** Local default avatar: linear neutral user icon. */
export const DEFAULT_USER_AVATAR = '/avatar-default.svg';

const BROKEN_AVATAR_PATTERN = /pstatp\.com|vcloud\/vadmin/;

export function resolveAvatarUrl(url?: string) {
  if (!url || BROKEN_AVATAR_PATTERN.test(url)) {
    return DEFAULT_USER_AVATAR;
  }
  if (url.startsWith('//')) {
    return `https:${url}`;
  }
  return url;
}
