Gitter migration: Setup redirects (rollout pt. 3)
[gitter.git] / modules / avatars / server / gravatar.js
blob46ef361ef04e46b4af0a065b447f3c37e924c500
1 'use strict';
3 var crypto = require('crypto');
5 function hashEmail(email) {
6 return crypto
7 .createHash('md5')
8 .update(email)
9 .digest('hex');
12 function forEmail(email, size) {
13 var checksum = crypto
14 .createHash('md5')
15 .update(email)
16 .digest('hex');
17 return forChecksum(checksum, size);
20 function forChecksum(checksum, size) {
21 if (size) {
22 return (
23 'https://secure.gravatar.com/avatar/' +
24 checksum +
25 '?d=https%3A%2F%2Favatars.gitter.im%2Fdefault.png&s=' +
26 size
28 } else {
29 return (
30 'https://secure.gravatar.com/avatar/' +
31 checksum +
32 '?d=https%3A%2F%2Favatars.gitter.im%2Fdefault.png'
37 module.exports = {
38 hashEmail: hashEmail,
39 forEmail: forEmail,
40 forChecksum: forChecksum