kopia lustrzana https://github.com/c9/core
Adding md5 of collab users emails for gravatar pictures
rodzic
f46f266c0a
commit
b7bae15ec2
|
@ -71,7 +71,7 @@
|
|||
"c9.ide.language.javascript.infer": "#b9c2e4bdb8",
|
||||
"c9.ide.language.jsonalyzer": "#a0549e14ff",
|
||||
"c9.ide.language.codeintel": "#0fe92d6f46",
|
||||
"c9.ide.collab": "#54aa1cbee0",
|
||||
"c9.ide.collab": "#78c38d73d1",
|
||||
"c9.ide.local": "#9169fec157",
|
||||
"c9.ide.find": "#e632ecf4be",
|
||||
"c9.ide.find.infiles": "#ad9ff74638",
|
||||
|
|
|
@ -196,12 +196,19 @@ define(function(require, exports, module) {
|
|||
return "<" + tag + " " + plugin.toXmlAttributes(attrs) + (noclose ? ">" : " />");
|
||||
};
|
||||
|
||||
function isMd5String(str) {
|
||||
return /^[0-9a-f]{32}$/.test(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the gravatar url for this user
|
||||
* @param {Number} size the size of the image
|
||||
*/
|
||||
plugin.getGravatarUrl = function getGravatarUrl(email, size, defaultImage) {
|
||||
var md5Email = apf.crypto.MD5.hex_md5((email || "").trim().toLowerCase());
|
||||
var md5Email = email
|
||||
if (!isMd5String(md5Email)) {
|
||||
md5Email = apf.crypto.MD5.hex_md5((email || "").trim().toLowerCase());
|
||||
}
|
||||
return "https://secure.gravatar.com/avatar/"
|
||||
+ md5Email + "?s=" + size + "&d=" + (defaultImage || "retro");
|
||||
};
|
||||
|
|
|
@ -9,6 +9,7 @@ require(["lib/architect/architect", "lib/chai/chai"], function (architect, chai)
|
|||
expect.setupArchitectTest([
|
||||
"plugins/c9.core/ext",
|
||||
"plugins/c9.core/util",
|
||||
"plugins/c9.ide.ui/lib_apf",
|
||||
// Mock plugins
|
||||
{
|
||||
consumes: [],
|
||||
|
@ -32,6 +33,15 @@ require(["lib/architect/architect", "lib/chai/chai"], function (architect, chai)
|
|||
});
|
||||
});
|
||||
|
||||
describe("getGravatarUrl", function() {
|
||||
it("Should hash a normal email", function() {
|
||||
expect(util.getGravatarUrl("test@test.com", 32)).to.match(/^https:\/\/secure.gravatar.com\/avatar\/b642b4217b34b1e8d3bd915fc65c4452.*/);
|
||||
});
|
||||
it("Should use not re-hash an md5 passed in", function() {
|
||||
expect(util.getGravatarUrl("b642b4217b34b1e8d3bd915fc65c4452", 32)).to.match(/^https:\/\/secure.gravatar.com\/avatar\/b642b4217b34b1e8d3bd915fc65c4452.*/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('normalizePath', function() {
|
||||
var normalizePath = util.normalizePath;
|
||||
it('should handle home in workspaceDir', function() {
|
||||
|
|
Ładowanie…
Reference in New Issue