Skip to content

Commit f7bc1e9

Browse files
author
Daan Sprenkels
committed
Remove blueimp-md5 dependency
Signed-off-by: Daan Sprenkels <[email protected]>
1 parent 318a37d commit f7bc1e9

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

lib/letter-avatars.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22
// external modules
3-
const md5 = require('blueimp-md5')
3+
const crypto = require('crypto')
44
const randomcolor = require('randomcolor')
55
const config = require('./config')
66

@@ -31,15 +31,19 @@ exports.generateAvatarURL = function (name, email = '', big = true) {
3131
email = '' + name + '@example.com'
3232
}
3333

34+
let hash = crypto.createHash('md5')
35+
hash.update(email.toLowerCase())
36+
let hexDigest = hash.digest('hex')
37+
3438
if (email !== '' && config.allowGravatar) {
35-
photo = 'https://www.gravatar.com/avatar/' + md5(email.toLowerCase())
39+
photo = 'https://www.gravatar.com/avatar/' + hexDigest;
3640
if (big) {
3741
photo += '?s=400'
3842
} else {
3943
photo += '?s=96'
4044
}
4145
} else {
42-
photo = config.serverURL + '/user/' + (name || email.substring(0, email.lastIndexOf('@')) || md5(email.toLowerCase())) + '/avatar.svg'
46+
photo = config.serverURL + '/user/' + (name || email.substring(0, email.lastIndexOf('@')) || hexDigest) + '/avatar.svg'
4347
}
4448
return photo
4549
}

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"aws-sdk": "^2.345.0",
2424
"azure-storage": "^2.7.0",
2525
"base64url": "^3.0.0",
26-
"blueimp-md5": "^2.6.0",
2726
"body-parser": "^1.15.2",
2827
"bootstrap": "^3.3.7",
2928
"bootstrap-validator": "^0.11.8",

0 commit comments

Comments
 (0)