Comparing version 1.3.0 to 1.3.1
@@ -0,1 +1,3 @@ | ||
### 1.3.1 | ||
- Enhancement: Detect MD5 hashes and not hash them again (opatut) | ||
### 1.3.0 | ||
@@ -2,0 +4,0 @@ - Implementing profiles (wlaurance - https://github.com/wlaurance) |
var crypto = require('crypto') | ||
, querystring = require('querystring'); | ||
var MD5_REGEX = /[0-9a-f]{32}/; | ||
var gravatar = module.exports = { | ||
url: function (email, options, protocol) { | ||
email = email || 'unspecified'; | ||
email = email.trim().toLowerCase(); | ||
var hash = email.match(MD5_REGEX) ? email : crypto.createHash('md5').update(email).digest('hex'); | ||
var baseURL; | ||
@@ -18,5 +22,7 @@ | ||
return baseURL + crypto.createHash('md5').update(email.toLowerCase().trim()).digest('hex') + query; | ||
return baseURL + hash + query; | ||
}, | ||
profile_url: function (email, options, https) { | ||
email = email.trim().toLowerCase(); | ||
var hash = email.match(MD5_REGEX) ? email : crypto.createHash('md5').update(email).digest('hex'); | ||
var format = options != undefined && options.format != undefined ? String(options.format) : 'json' | ||
@@ -29,4 +35,4 @@ //delete options.format | ||
return baseURL + crypto.createHash('md5').update(email.toLowerCase().trim()).digest('hex') + '.' + format + query; | ||
return baseURL + hash + '.' + format + query; | ||
} | ||
}; |
@@ -5,3 +5,3 @@ { | ||
"keywords" : [ "gravatar", "avatar", "package.json" ], | ||
"version" : "1.3.0", | ||
"version" : "1.3.1", | ||
"author" : "Emerson Macedo <emerleite@gmail.com>", | ||
@@ -8,0 +8,0 @@ "repository" : { "type": "git", |
@@ -22,2 +22,7 @@ var should = require('should') | ||
it('should detect MD5 hashes and not hash them again', function() { | ||
gravatar.url('93e9084aa289b7f1f5e4ab6716a56c3b').should.be.equal(baseNoProtocolURL + "93e9084aa289b7f1f5e4ab6716a56c3b"); | ||
gravatar.url('93E9084AA289B7F1F5E4AB6716A56C3B').should.be.equal(baseNoProtocolURL + "93e9084aa289b7f1f5e4ab6716a56c3b"); | ||
}); | ||
it('should generate uri with user passed parameters', function() { | ||
@@ -24,0 +29,0 @@ var gravatarURL = gravatar.url('emerleite@gmail.com', { s: '200', f: 'y', r: 'g', d: '404'}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8946
80