import crypto from 'crypto';

export function getGravatarUrl(email, size = 32) {
  if (email === undefined || typeof email !== 'string') {
    return 'https://www.gravatar.com/avatar/';
  } else {
    const hash = crypto
      .createHash('md5')
      .update(email.toLowerCase().trim())
      .digest('hex');
    return `https://www.gravatar.com/avatar/${hash}?s=${size}&d=identicon`;
  }
}
