Socket
Socket
Sign inDemoInstall

gravatar

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gravatar - npm Package Compare versions

Comparing version 1.3.0 to 1.3.1

2

Changelog.md

@@ -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)

10

lib/gravatar.js
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'});

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc