mirror of
https://github.com/azures04/crafatar.git
synced 2026-03-21 23:41:18 +01:00
add support for slim renders, fixes #125, adjust tests
This commit is contained in:
parent
7eed1fa09b
commit
3c21a59c94
51
lib/cache.js
51
lib/cache.js
@ -67,15 +67,14 @@ exp.get_redis = function() {
|
|||||||
// updates the redis instance's server_info object
|
// updates the redis instance's server_info object
|
||||||
// callback: error, info object
|
// callback: error, info object
|
||||||
exp.info = function(callback) {
|
exp.info = function(callback) {
|
||||||
redis.info(function (err, res) {
|
redis.info(function(err, res) {
|
||||||
|
|
||||||
// parse the info command and store it in redis.server_info
|
// parse the info command and store it in redis.server_info
|
||||||
|
|
||||||
// this code block was taken from mranney/node_redis#on_info_cmd
|
// this code block was taken from mranney/node_redis#on_info_cmd
|
||||||
// http://git.io/LBUNbg
|
// http://git.io/LBUNbg
|
||||||
var lines = res.toString().split("\r\n");
|
var lines = res.toString().split("\r\n");
|
||||||
var obj = {};
|
var obj = {};
|
||||||
lines.forEach(function (line) {
|
lines.forEach(function(line) {
|
||||||
var parts = line.split(":");
|
var parts = line.split(":");
|
||||||
if (parts[1]) {
|
if (parts[1]) {
|
||||||
obj[parts[0]] = parts[1];
|
obj[parts[0]] = parts[1];
|
||||||
@ -109,31 +108,36 @@ exp.update_timestamp = function(rid, userId, hash, temp, callback) {
|
|||||||
update_file_date(rid, hash);
|
update_file_date(rid, hash);
|
||||||
};
|
};
|
||||||
|
|
||||||
// create the key +userId+, store +skin_hash+, +cape_hash+ and time
|
// create the key +userId+, store +skin_hash+, +cape_hash+, +slim+ and current time
|
||||||
// if either +skin_hash+ or +cape_hash+ are undefined, they will not be stored
|
// if +skin_hash+ or +cape_hash+ are undefined, they aren't stored
|
||||||
// this feature can be used to write both cape and skin at separate times
|
// this is useful to store cape and skin at separate times, without overwriting the other
|
||||||
|
// +slim+ can be true (alex) or false (steve)
|
||||||
// +callback+ contans error
|
// +callback+ contans error
|
||||||
exp.save_hash = function(rid, userId, skin_hash, cape_hash, callback) {
|
exp.save_hash = function(rid, userId, skin_hash, cape_hash, slim, callback) {
|
||||||
logging.debug(rid, "caching skin:" + skin_hash + " cape:" + cape_hash);
|
logging.debug(rid, "caching skin:" + skin_hash + " cape:" + cape_hash);
|
||||||
var time = Date.now();
|
|
||||||
// store shorter null byte instead of "null"
|
// store shorter null value instead of "null" string
|
||||||
skin_hash = (skin_hash === null ? "" : skin_hash);
|
skin_hash = skin_hash === null ? "" : skin_hash;
|
||||||
cape_hash = (cape_hash === null ? "" : cape_hash);
|
cape_hash = cape_hash === null ? "" : cape_hash;
|
||||||
|
|
||||||
// store userId in lower case if not null
|
// store userId in lower case if not null
|
||||||
userId = userId && userId.toLowerCase();
|
userId = userId && userId.toLowerCase();
|
||||||
if (skin_hash === undefined) {
|
|
||||||
redis.hmset(userId, "c", cape_hash, "t", time, function(err) {
|
var args = [];
|
||||||
callback(err);
|
if (cape_hash !== undefined) {
|
||||||
});
|
args.push("c", cape_hash);
|
||||||
} else if (cape_hash === undefined) {
|
|
||||||
redis.hmset(userId, "s", skin_hash, "t", time, function(err) {
|
|
||||||
callback(err);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
redis.hmset(userId, "s", skin_hash, "c", cape_hash, "t", time, function(err) {
|
|
||||||
callback(err);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
if (skin_hash !== undefined) {
|
||||||
|
args.push("s", skin_hash);
|
||||||
|
}
|
||||||
|
if (slim !== undefined) {
|
||||||
|
args.push("a", Number(!!slim));
|
||||||
|
}
|
||||||
|
args.push("t", Date.now());
|
||||||
|
|
||||||
|
redis.hmset(userId, args, function(err) {
|
||||||
|
callback(err);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// removes the hash for +userId+ from the cache
|
// removes the hash for +userId+ from the cache
|
||||||
@ -155,6 +159,7 @@ exp.get_details = function(userId, callback) {
|
|||||||
details = {
|
details = {
|
||||||
skin: data.s === "" ? null : data.s,
|
skin: data.s === "" ? null : data.s,
|
||||||
cape: data.c === "" ? null : data.c,
|
cape: data.c === "" ? null : data.c,
|
||||||
|
slim: data.a === 1,
|
||||||
time: Number(data.t)
|
time: Number(data.t)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,12 +21,12 @@ function get_hash(url) {
|
|||||||
// face and face+helm images are extracted and stored to files
|
// face and face+helm images are extracted and stored to files
|
||||||
// callback: error, skin hash
|
// callback: error, skin hash
|
||||||
function store_skin(rid, userId, profile, cache_details, callback) {
|
function store_skin(rid, userId, profile, cache_details, callback) {
|
||||||
networking.get_skin_url(rid, userId, profile, function(err, url) {
|
networking.get_skin_info(rid, userId, profile, function(err, url, slim) {
|
||||||
if (!err && url) {
|
if (!err && url) {
|
||||||
var skin_hash = get_hash(url);
|
var skin_hash = get_hash(url);
|
||||||
if (cache_details && cache_details.skin === skin_hash) {
|
if (cache_details && cache_details.skin === skin_hash) {
|
||||||
cache.update_timestamp(rid, userId, skin_hash, false, function(cache_err) {
|
cache.update_timestamp(rid, userId, skin_hash, false, function(cache_err) {
|
||||||
callback(cache_err, skin_hash);
|
callback(cache_err, skin_hash, slim);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
logging.debug(rid, "new skin hash:", skin_hash);
|
logging.debug(rid, "new skin hash:", skin_hash);
|
||||||
@ -36,27 +36,27 @@ function store_skin(rid, userId, profile, cache_details, callback) {
|
|||||||
fs.exists(facepath, function(exists) {
|
fs.exists(facepath, function(exists) {
|
||||||
if (exists) {
|
if (exists) {
|
||||||
logging.debug(rid, "skin already exists, not downloading");
|
logging.debug(rid, "skin already exists, not downloading");
|
||||||
callback(null, skin_hash);
|
callback(null, skin_hash, slim);
|
||||||
} else {
|
} else {
|
||||||
networking.get_from(rid, url, function(img, response, err1) {
|
networking.get_from(rid, url, function(img, response, err1) {
|
||||||
if (err1 || !img) {
|
if (err1 || !img) {
|
||||||
callback(err1, null);
|
callback(err1, null, slim);
|
||||||
} else {
|
} else {
|
||||||
skins.save_image(img, skinpath, function(skin_err) {
|
skins.save_image(img, skinpath, function(skin_err) {
|
||||||
if (skin_err) {
|
if (skin_err) {
|
||||||
logging.error(rid, skin_err);
|
logging.error(rid, skin_err);
|
||||||
callback(skin_err, null);
|
callback(skin_err, null, slim);
|
||||||
} else {
|
} else {
|
||||||
skins.extract_face(img, facepath, function(err2) {
|
skins.extract_face(img, facepath, function(err2) {
|
||||||
if (err2) {
|
if (err2) {
|
||||||
logging.error(rid, err2.stack);
|
logging.error(rid, err2.stack);
|
||||||
callback(err2, null);
|
callback(err2, null, slim);
|
||||||
} else {
|
} else {
|
||||||
logging.debug(rid, "face extracted");
|
logging.debug(rid, "face extracted");
|
||||||
skins.extract_helm(rid, facepath, img, helmpath, function(err3) {
|
skins.extract_helm(rid, facepath, img, helmpath, function(err3) {
|
||||||
logging.debug(rid, "helm extracted");
|
logging.debug(rid, "helm extracted");
|
||||||
logging.debug(rid, helmpath);
|
logging.debug(rid, helmpath);
|
||||||
callback(err3, skin_hash);
|
callback(err3, skin_hash, slim);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -129,7 +129,7 @@ function push_request(userId, type, fun) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// calls back all queued requests that match userId and type
|
// calls back all queued requests that match userId and type
|
||||||
function resume(userId, type, err, hash) {
|
function resume(userId, type, err, hash, slim) {
|
||||||
var callbacks = requests[type][userId];
|
var callbacks = requests[type][userId];
|
||||||
if (callbacks) {
|
if (callbacks) {
|
||||||
if (callbacks.length > 1) {
|
if (callbacks.length > 1) {
|
||||||
@ -138,7 +138,7 @@ function resume(userId, type, err, hash) {
|
|||||||
|
|
||||||
for (var i = 0; i < callbacks.length; i++) {
|
for (var i = 0; i < callbacks.length; i++) {
|
||||||
// continue the request
|
// continue the request
|
||||||
callbacks[i](err, hash);
|
callbacks[i](err, hash, slim);
|
||||||
// remove from array
|
// remove from array
|
||||||
callbacks.splice(i, 1);
|
callbacks.splice(i, 1);
|
||||||
i--;
|
i--;
|
||||||
@ -167,34 +167,34 @@ function store_images(rid, userId, cache_details, type, callback) {
|
|||||||
// error or uuid without profile
|
// error or uuid without profile
|
||||||
if (!err && !profile) {
|
if (!err && !profile) {
|
||||||
// no error, but uuid without profile
|
// no error, but uuid without profile
|
||||||
cache.save_hash(rid, userId, null, null, function(cache_err) {
|
cache.save_hash(rid, userId, null, null, undefined, function(cache_err) {
|
||||||
// we have no profile, so we have neither skin nor cape
|
// we have no profile, so we have neither skin nor cape
|
||||||
resume(userId, "skin", cache_err, null);
|
resume(userId, "skin", cache_err, null, false);
|
||||||
resume(userId, "cape", cache_err, null);
|
resume(userId, "cape", cache_err, null, false);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// an error occured, not caching. we can try in 60 seconds
|
// an error occured, not caching. we can try in 60 seconds
|
||||||
resume(userId, type, err, null);
|
resume(userId, type, err, null, false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// no error and we have a profile (if it's a uuid)
|
// no error and we have a profile (if it's a uuid)
|
||||||
store_skin(rid, userId, profile, cache_details, function(store_err, skin_hash) {
|
store_skin(rid, userId, profile, cache_details, function(store_err, skin_hash, slim) {
|
||||||
if (store_err && !skin_hash) {
|
if (store_err && !skin_hash) {
|
||||||
// an error occured, not caching. we can try in 60 seconds
|
// an error occured, not caching. we can try in 60 seconds
|
||||||
resume(userId, "skin", store_err, null);
|
resume(userId, "skin", store_err, null, slim);
|
||||||
} else {
|
} else {
|
||||||
cache.save_hash(rid, userId, skin_hash, undefined, function(cache_err) {
|
cache.save_hash(rid, userId, skin_hash, undefined, slim, function(cache_err) {
|
||||||
resume(userId, "skin", (store_err || cache_err), skin_hash);
|
resume(userId, "skin", (store_err || cache_err), skin_hash, slim);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
store_cape(rid, userId, profile, cache_details, function(store_err, cape_hash) {
|
store_cape(rid, userId, profile, cache_details, function(store_err, cape_hash) {
|
||||||
if (store_err && !cape_hash) {
|
if (store_err && !cape_hash) {
|
||||||
// an error occured, not caching. we can try in 60 seconds
|
// an error occured, not caching. we can try in 60 seconds
|
||||||
resume(userId, "cape", (store_err), cape_hash);
|
resume(userId, "cape", (store_err), cape_hash, false);
|
||||||
} else {
|
} else {
|
||||||
cache.save_hash(rid, userId, undefined, cape_hash, function(cache_err) {
|
cache.save_hash(rid, userId, undefined, cape_hash, undefined, function(cache_err) {
|
||||||
resume(userId, "cape", (store_err || cache_err), cape_hash);
|
resume(userId, "cape", (store_err || cache_err), cape_hash, false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -212,7 +212,7 @@ exp.id_valid = function(userId) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// decides whether to get a +type+ image for +userId+ from disk or to download it
|
// decides whether to get a +type+ image for +userId+ from disk or to download it
|
||||||
// callback: error, status, hash
|
// callback: error, status, hash, slim
|
||||||
// for status, see response.js
|
// for status, see response.js
|
||||||
exp.get_image_hash = function(rid, userId, type, callback) {
|
exp.get_image_hash = function(rid, userId, type, callback) {
|
||||||
cache.get_details(userId, function(err, cache_details) {
|
cache.get_details(userId, function(err, cache_details) {
|
||||||
@ -221,12 +221,12 @@ exp.get_image_hash = function(rid, userId, type, callback) {
|
|||||||
cached_hash = type === "skin" ? cache_details.skin : cache_details.cape;
|
cached_hash = type === "skin" ? cache_details.skin : cache_details.cape;
|
||||||
}
|
}
|
||||||
if (err) {
|
if (err) {
|
||||||
callback(err, -1, null);
|
callback(err, -1, null, false);
|
||||||
} else {
|
} else {
|
||||||
if (cache_details && cache_details[type] !== undefined && cache_details.time + config.caching.local * 1000 >= Date.now()) {
|
if (cache_details && cache_details[type] !== undefined && cache_details.time + config.caching.local * 1000 >= Date.now()) {
|
||||||
// use cached image
|
// use cached image
|
||||||
logging.debug(rid, "userId cached & recently updated");
|
logging.debug(rid, "userId cached & recently updated");
|
||||||
callback(null, (cached_hash ? 1 : 0), cached_hash);
|
callback(null, (cached_hash ? 1 : 0), cached_hash, cache_details.slim);
|
||||||
} else {
|
} else {
|
||||||
// download image
|
// download image
|
||||||
if (cache_details) {
|
if (cache_details) {
|
||||||
@ -234,18 +234,18 @@ exp.get_image_hash = function(rid, userId, type, callback) {
|
|||||||
} else {
|
} else {
|
||||||
logging.debug(rid, "userId not cached");
|
logging.debug(rid, "userId not cached");
|
||||||
}
|
}
|
||||||
store_images(rid, userId, cache_details, type, function(store_err, new_hash) {
|
store_images(rid, userId, cache_details, type, function(store_err, new_hash, slim) {
|
||||||
if (store_err) {
|
if (store_err) {
|
||||||
// we might have a cached hash although an error occured
|
// we might have a cached hash although an error occured
|
||||||
// (e.g. Mojang servers not reachable, using outdated hash)
|
// (e.g. Mojang servers not reachable, using outdated hash)
|
||||||
cache.update_timestamp(rid, userId, cached_hash, true, function(err2) {
|
cache.update_timestamp(rid, userId, cached_hash, true, function(err2) {
|
||||||
callback(err2 || store_err, -1, cache_details && cached_hash);
|
callback(err2 || store_err, -1, cache_details && cached_hash, slim);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var status = cache_details && (cached_hash === new_hash) ? 3 : 2;
|
var status = cache_details && (cached_hash === new_hash) ? 3 : 2;
|
||||||
logging.debug(rid, "cached hash:", (cache_details && cached_hash));
|
logging.debug(rid, "cached hash:", (cache_details && cached_hash));
|
||||||
logging.debug(rid, "new hash:", new_hash);
|
logging.debug(rid, "new hash:", new_hash);
|
||||||
callback(null, status, new_hash);
|
callback(null, status, new_hash, slim);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -259,7 +259,7 @@ exp.get_image_hash = function(rid, userId, type, callback) {
|
|||||||
// image is the user's face+helm when helm is true, or the face otherwise
|
// image is the user's face+helm when helm is true, or the face otherwise
|
||||||
// for status, see get_image_hash
|
// for status, see get_image_hash
|
||||||
exp.get_avatar = function(rid, userId, helm, size, callback) {
|
exp.get_avatar = function(rid, userId, helm, size, callback) {
|
||||||
exp.get_image_hash(rid, userId, "skin", function(err, status, skin_hash) {
|
exp.get_image_hash(rid, userId, "skin", function(err, status, skin_hash, slim) {
|
||||||
if (skin_hash) {
|
if (skin_hash) {
|
||||||
var facepath = path.join(__dirname, "..", config.directories.faces, skin_hash + ".png");
|
var facepath = path.join(__dirname, "..", config.directories.faces, skin_hash + ".png");
|
||||||
var helmpath = path.join(__dirname, "..", config.directories.helms, skin_hash + ".png");
|
var helmpath = path.join(__dirname, "..", config.directories.helms, skin_hash + ".png");
|
||||||
@ -286,23 +286,23 @@ exp.get_avatar = function(rid, userId, helm, size, callback) {
|
|||||||
// handles requests for +userId+ skins
|
// handles requests for +userId+ skins
|
||||||
// callback: error, skin hash, status, image buffer
|
// callback: error, skin hash, status, image buffer
|
||||||
exp.get_skin = function(rid, userId, callback) {
|
exp.get_skin = function(rid, userId, callback) {
|
||||||
exp.get_image_hash(rid, userId, "skin", function(err, status, skin_hash) {
|
exp.get_image_hash(rid, userId, "skin", function(err, status, skin_hash, slim) {
|
||||||
if (skin_hash) {
|
if (skin_hash) {
|
||||||
var skinpath = path.join(__dirname, "..", config.directories.skins, skin_hash + ".png");
|
var skinpath = path.join(__dirname, "..", config.directories.skins, skin_hash + ".png");
|
||||||
fs.exists(skinpath, function(exists) {
|
fs.exists(skinpath, function(exists) {
|
||||||
if (exists) {
|
if (exists) {
|
||||||
logging.debug(rid, "skin already exists, not downloading");
|
logging.debug(rid, "skin already exists, not downloading");
|
||||||
skins.open_skin(rid, skinpath, function(skin_err, img) {
|
skins.open_skin(rid, skinpath, function(skin_err, img) {
|
||||||
callback(skin_err || err, skin_hash, status, img);
|
callback(skin_err || err, skin_hash, status, img, slim);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
networking.save_texture(rid, skin_hash, skinpath, function(net_err, response, img) {
|
networking.save_texture(rid, skin_hash, skinpath, function(net_err, response, img) {
|
||||||
callback(net_err || err, skin_hash, status, img);
|
callback(net_err || err, skin_hash, status, img, slim);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
callback(err, null, status, null);
|
callback(err, null, status, null, slim);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -318,12 +318,12 @@ function get_type(helm, body) {
|
|||||||
// handles creations of 3D renders
|
// handles creations of 3D renders
|
||||||
// callback: error, skin hash, image buffer
|
// callback: error, skin hash, image buffer
|
||||||
exp.get_render = function(rid, userId, scale, helm, body, callback) {
|
exp.get_render = function(rid, userId, scale, helm, body, callback) {
|
||||||
exp.get_skin(rid, userId, function(err, skin_hash, status, img) {
|
exp.get_skin(rid, userId, function(err, skin_hash, status, img, slim) {
|
||||||
if (!skin_hash) {
|
if (!skin_hash) {
|
||||||
callback(err, status, skin_hash, null);
|
callback(err, status, skin_hash, null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var renderpath = path.join(__dirname, "..", config.directories.renders, [skin_hash, scale, get_type(helm, body)].join("-") + ".png");
|
var renderpath = path.join(__dirname, "..", config.directories.renders, [skin_hash, scale, get_type(helm, body), slim ? "s" : "t"].join("-") + ".png");
|
||||||
fs.exists(renderpath, function(exists) {
|
fs.exists(renderpath, function(exists) {
|
||||||
if (exists) {
|
if (exists) {
|
||||||
renders.open_render(rid, renderpath, function(render_err, rendered_img) {
|
renders.open_render(rid, renderpath, function(render_err, rendered_img) {
|
||||||
@ -335,7 +335,7 @@ exp.get_render = function(rid, userId, scale, helm, body, callback) {
|
|||||||
callback(err, 0, skin_hash, null);
|
callback(err, 0, skin_hash, null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
renders.draw_model(rid, img, scale, helm, body, function(draw_err, drawn_img) {
|
renders.draw_model(rid, img, scale, helm, body, slim, function(draw_err, drawn_img) {
|
||||||
if (draw_err) {
|
if (draw_err) {
|
||||||
callback(draw_err, -1, skin_hash, null);
|
callback(draw_err, -1, skin_hash, null);
|
||||||
} else if (!drawn_img) {
|
} else if (!drawn_img) {
|
||||||
@ -357,7 +357,7 @@ exp.get_render = function(rid, userId, scale, helm, body, callback) {
|
|||||||
// handles requests for +userId+ capes
|
// handles requests for +userId+ capes
|
||||||
// callback: error, cape hash, status, image buffer
|
// callback: error, cape hash, status, image buffer
|
||||||
exp.get_cape = function(rid, userId, callback) {
|
exp.get_cape = function(rid, userId, callback) {
|
||||||
exp.get_image_hash(rid, userId, "cape", function(err, status, cape_hash) {
|
exp.get_image_hash(rid, userId, "cape", function(err, status, cape_hash, slim) {
|
||||||
if (!cape_hash) {
|
if (!cape_hash) {
|
||||||
callback(err, null, status, null);
|
callback(err, null, status, null);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -3,6 +3,7 @@ var logging = require("./logging");
|
|||||||
var request = require("request");
|
var request = require("request");
|
||||||
var config = require("../config");
|
var config = require("../config");
|
||||||
var skins = require("./skins");
|
var skins = require("./skins");
|
||||||
|
require("./object-patch");
|
||||||
|
|
||||||
var session_url = "https://sessionserver.mojang.com/session/minecraft/profile/";
|
var session_url = "https://sessionserver.mojang.com/session/minecraft/profile/";
|
||||||
var skins_url = "https://skins.minecraft.net/MinecraftSkins/";
|
var skins_url = "https://skins.minecraft.net/MinecraftSkins/";
|
||||||
@ -22,40 +23,46 @@ function extract_url(profile, type) {
|
|||||||
if (prop.name === "textures") {
|
if (prop.name === "textures") {
|
||||||
var json = new Buffer(prop.value, "base64").toString();
|
var json = new Buffer(prop.value, "base64").toString();
|
||||||
var props = JSON.parse(json);
|
var props = JSON.parse(json);
|
||||||
url = props && props.textures && props.textures[type] && props.textures[type].url || null;
|
url = Object.get(props, "textures." + type + ".url") || null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper method that calls `get_username_url` or `get_uuid_url` based on the +usedId+
|
// extracts the +type+ [SKIN|CAPE] URL
|
||||||
|
// from the nested & encoded +profile+ object
|
||||||
|
// returns the if the model is "slim"
|
||||||
|
function extract_model(profile) {
|
||||||
|
var slim = null;
|
||||||
|
if (profile && profile.properties) {
|
||||||
|
profile.properties.forEach(function(prop) {
|
||||||
|
if (prop.name === "textures") {
|
||||||
|
var json = new Buffer(prop.value, "base64").toString();
|
||||||
|
var props = JSON.parse(json);
|
||||||
|
slim = Object.get(props, "textures.SKIN.metadata.model");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return slim === "slim";
|
||||||
|
}
|
||||||
|
|
||||||
|
// helper method that calls `get_username_url` or `get_uuid_info` based on the +usedId+
|
||||||
// +userId+ is used for usernames, while +profile+ is used for UUIDs
|
// +userId+ is used for usernames, while +profile+ is used for UUIDs
|
||||||
function get_url(rid, userId, profile, type, callback) {
|
// callback: error, url, slim
|
||||||
|
function get_info(rid, userId, profile, type, callback) {
|
||||||
if (userId.length <= 16) {
|
if (userId.length <= 16) {
|
||||||
// username
|
// username
|
||||||
exp.get_username_url(rid, userId, type, function(err, url) {
|
exp.get_username_url(rid, userId, type, function(err, url) {
|
||||||
callback(err, url || null);
|
callback(err, url || null, false);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
exp.get_uuid_url(profile, type, function(url) {
|
exp.get_uuid_info(profile, type, function(url, slim) {
|
||||||
callback(null, url || null);
|
callback(null, url || null, slim);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// exracts the skin URL of a +profile+ object
|
|
||||||
// returns null when no URL found (user has no skin)
|
|
||||||
exp.extract_skin_url = function(profile) {
|
|
||||||
return extract_url(profile, "SKIN");
|
|
||||||
};
|
|
||||||
|
|
||||||
// exracts the cape URL of a +profile+ object
|
|
||||||
// returns null when no URL found (user has no cape)
|
|
||||||
exp.extract_cape_url = function(profile) {
|
|
||||||
return extract_url(profile, "CAPE");
|
|
||||||
};
|
|
||||||
|
|
||||||
// performs a GET request to the +url+
|
// performs a GET request to the +url+
|
||||||
// +options+ object includes these options:
|
// +options+ object includes these options:
|
||||||
// encoding (string), default is to return a buffer
|
// encoding (string), default is to return a buffer
|
||||||
@ -112,6 +119,7 @@ exp.get_from = function(rid, url, callback) {
|
|||||||
// the skin url is taken from the HTTP redirect
|
// the skin url is taken from the HTTP redirect
|
||||||
// type reference is above
|
// type reference is above
|
||||||
exp.get_username_url = function(rid, name, type, callback) {
|
exp.get_username_url = function(rid, name, type, callback) {
|
||||||
|
type = Number(type === "CAPE");
|
||||||
exp.get_from(rid, mojang_urls[type] + name + ".png", function(body, response, err) {
|
exp.get_from(rid, mojang_urls[type] + name + ".png", function(body, response, err) {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
if (response) {
|
if (response) {
|
||||||
@ -126,15 +134,24 @@ exp.get_username_url = function(rid, name, type, callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// gets the URL for a skin/cape from the profile
|
// gets the URL for a skin/cape from the profile
|
||||||
// +type+ specifies which to retrieve
|
// +type+ "SKIN" or "CAPE", specifies which to retrieve
|
||||||
exp.get_uuid_url = function(profile, type, callback) {
|
// callback: url, slim
|
||||||
var url = null;
|
exp.get_uuid_info = function(profile, type, callback) {
|
||||||
if (type === 0) {
|
var properties = Object.get(profile, "properties") || [];
|
||||||
url = exp.extract_skin_url(profile);
|
properties.forEach(function(prop) {
|
||||||
} else if (type === 1) {
|
if (prop.name === "textures") {
|
||||||
url = exp.extract_cape_url(profile);
|
var json = new Buffer(prop.value, "base64").toString();
|
||||||
|
profile = JSON.parse(json);
|
||||||
}
|
}
|
||||||
callback(url || null);
|
});
|
||||||
|
|
||||||
|
var url = Object.get(profile, "textures." + type + ".url");
|
||||||
|
var slim;
|
||||||
|
if (type === "SKIN") {
|
||||||
|
slim = Object.get(profile, "textures.SKIN.metadata.model");
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(url || null, !!slim);
|
||||||
};
|
};
|
||||||
|
|
||||||
// make a request to sessionserver for +uuid+
|
// make a request to sessionserver for +uuid+
|
||||||
@ -149,20 +166,17 @@ exp.get_profile = function(rid, uuid, callback) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// get the skin URL for +userId+
|
// get the skin URL and type for +userId+
|
||||||
// +profile+ is used if +userId+ is a uuid
|
// +profile+ is used if +userId+ is a uuid
|
||||||
exp.get_skin_url = function(rid, userId, profile, callback) {
|
// callback: error, url, slim
|
||||||
get_url(rid, userId, profile, 0, function(err, url) {
|
exp.get_skin_info = function(rid, userId, profile, callback) {
|
||||||
callback(err, url);
|
get_info(rid, userId, profile, "SKIN", callback);
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// get the cape URL for +userId+
|
// get the cape URL for +userId+
|
||||||
// +profile+ is used if +userId+ is a uuid
|
// +profile+ is used if +userId+ is a uuid
|
||||||
exp.get_cape_url = function(rid, userId, profile, callback) {
|
exp.get_cape_url = function(rid, userId, profile, callback) {
|
||||||
get_url(rid, userId, profile, 1, function(err, url) {
|
get_info(rid, userId, profile, "CAPE", callback);
|
||||||
callback(err, url);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// download the +tex_hash+ image from the texture server
|
// download the +tex_hash+ image from the texture server
|
||||||
|
|||||||
22
lib/object-patch.js
Normal file
22
lib/object-patch.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// Adds Object.get function
|
||||||
|
// +pathstr+ is a string of dot-separated nested properties on +ojb+
|
||||||
|
// returns undefined if any of the properties do not exist
|
||||||
|
// returns the value of the last property otherwise
|
||||||
|
//
|
||||||
|
// Object.get({"foo": {"bar": 123}}, "foo.bar"); // 123
|
||||||
|
// Object.get({"foo": {"bar": 123}}, "bar.foo"); // undefined
|
||||||
|
Object.get = function(obj, pathstr) {
|
||||||
|
var path = pathstr.split(".");
|
||||||
|
var result = obj;
|
||||||
|
|
||||||
|
for (var i = 0; i < path.length; i++) {
|
||||||
|
var key = path[i];
|
||||||
|
if (!result || !result.hasOwnProperty(key)) {
|
||||||
|
return undefined;
|
||||||
|
} else {
|
||||||
|
result = result[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
};
|
||||||
@ -78,7 +78,7 @@ function flip(src) {
|
|||||||
var skew_a = 26 / 45; // 0.57777777
|
var skew_a = 26 / 45; // 0.57777777
|
||||||
var skew_b = skew_a * 2; // 1.15555555
|
var skew_b = skew_a * 2; // 1.15555555
|
||||||
|
|
||||||
exp.draw_model = function(rid, img, scale, overlay, is_body, callback) {
|
exp.draw_model = function(rid, img, scale, overlay, is_body, slim, callback) {
|
||||||
var canvas = new Canvas();
|
var canvas = new Canvas();
|
||||||
canvas.width = scale * 20;
|
canvas.width = scale * 20;
|
||||||
canvas.height = scale * (is_body ? 45.1 : 18.5);
|
canvas.height = scale * (is_body ? 45.1 : 18.5);
|
||||||
@ -88,7 +88,7 @@ exp.draw_model = function(rid, img, scale, overlay, is_body, callback) {
|
|||||||
|
|
||||||
skin.onload = function() {
|
skin.onload = function() {
|
||||||
var old_skin = skin.height === 32;
|
var old_skin = skin.height === 32;
|
||||||
var arm_width = 4;
|
var arm_width = slim ? 3 : 4;
|
||||||
|
|
||||||
/* eslint-disable no-multi-spaces */
|
/* eslint-disable no-multi-spaces */
|
||||||
var head_top = resize(removeTransparency(getPart(skin, 8, 0, 8, 8, 1)), scale);
|
var head_top = resize(removeTransparency(getPart(skin, 8, 0, 8, 8, 1)), scale);
|
||||||
|
|||||||
@ -36,7 +36,7 @@ function handle_default(rid, scale, helm, body, img_status, userId, size, def, r
|
|||||||
// handle steve and alex
|
// handle steve and alex
|
||||||
fs.readFile(path.join(__dirname, "..", "public", "images", def + "_skin.png"), function(fs_err, buf) {
|
fs.readFile(path.join(__dirname, "..", "public", "images", def + "_skin.png"), function(fs_err, buf) {
|
||||||
// we render the default skins, but not custom images
|
// we render the default skins, but not custom images
|
||||||
renders.draw_model(rid, buf, scale, helm, body, function(render_err, def_img) {
|
renders.draw_model(rid, buf, scale, helm, body, def === "alex", function(render_err, def_img) {
|
||||||
callback({
|
callback({
|
||||||
status: img_status,
|
status: img_status,
|
||||||
body: def_img,
|
body: def_img,
|
||||||
|
|||||||
52
test/test.js
52
test/test.js
@ -139,7 +139,7 @@ describe("Crafatar", function() {
|
|||||||
networking.get_profile(rid, "ec561538f3fd461daff5086b22154bce", function(err, profile) {
|
networking.get_profile(rid, "ec561538f3fd461daff5086b22154bce", function(err, profile) {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
assert.notStrictEqual(profile, null);
|
assert.notStrictEqual(profile, null);
|
||||||
networking.get_uuid_url(profile, 1, function(url) {
|
networking.get_uuid_info(profile, "CAPE", function(url) {
|
||||||
assert.strictEqual(url, null);
|
assert.strictEqual(url, null);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -548,17 +548,17 @@ describe("Crafatar", function() {
|
|||||||
"head render with existing username": {
|
"head render with existing username": {
|
||||||
url: "http://localhost:3000/renders/head/jeb_?scale=2",
|
url: "http://localhost:3000/renders/head/jeb_?scale=2",
|
||||||
etag: '"a846b82963"',
|
etag: '"a846b82963"',
|
||||||
crc32: [353633671, 370672768]
|
crc32: [3487896679, 3001090792]
|
||||||
},
|
},
|
||||||
"head render with non-existent username": {
|
"head render with non-existent username": {
|
||||||
url: "http://localhost:3000/renders/head/0?scale=2",
|
url: "http://localhost:3000/renders/head/0?scale=2",
|
||||||
etag: '"steve"',
|
etag: '"steve"',
|
||||||
crc32: [883439147, 433083528]
|
crc32: [3257141069, 214248305]
|
||||||
},
|
},
|
||||||
"head render with non-existent username defaulting to alex": {
|
"head render with non-existent username defaulting to alex": {
|
||||||
url: "http://localhost:3000/renders/head/0?scale=2&default=alex",
|
url: "http://localhost:3000/renders/head/0?scale=2&default=alex",
|
||||||
etag: '"alex"',
|
etag: '"alex"',
|
||||||
crc32: [1240086237, 1108800327]
|
crc32: [263450586, 3116770561]
|
||||||
},
|
},
|
||||||
"head render with non-existent username defaulting to username": {
|
"head render with non-existent username defaulting to username": {
|
||||||
url: "http://localhost:3000/avatars/0?scale=2&default=jeb_",
|
url: "http://localhost:3000/avatars/0?scale=2&default=jeb_",
|
||||||
@ -578,17 +578,17 @@ describe("Crafatar", function() {
|
|||||||
"helm head render with existing username": {
|
"helm head render with existing username": {
|
||||||
url: "http://localhost:3000/renders/head/jeb_?scale=2&helm",
|
url: "http://localhost:3000/renders/head/jeb_?scale=2&helm",
|
||||||
etag: '"a846b82963"',
|
etag: '"a846b82963"',
|
||||||
crc32: [3456497067, 3490318764]
|
crc32: [762377383, 1726474987]
|
||||||
},
|
},
|
||||||
"helm head render with non-existent username": {
|
"helm head render with non-existent username": {
|
||||||
url: "http://localhost:3000/renders/head/0?scale=2&helm",
|
url: "http://localhost:3000/renders/head/0?scale=2&helm",
|
||||||
etag: '"steve"',
|
etag: '"steve"',
|
||||||
crc32: [1858563554, 2647471936]
|
crc32: [3257141069, 214248305]
|
||||||
},
|
},
|
||||||
"helm head render with non-existent username defaulting to alex": {
|
"helm head render with non-existent username defaulting to alex": {
|
||||||
url: "http://localhost:3000/renders/head/0?scale=2&helm&default=alex",
|
url: "http://localhost:3000/renders/head/0?scale=2&helm&default=alex",
|
||||||
etag: '"alex"',
|
etag: '"alex"',
|
||||||
crc32: [2963161105, 1769904825]
|
crc32: [263450586, 3116770561]
|
||||||
},
|
},
|
||||||
"helm head render with non-existent username defaulting to username": {
|
"helm head render with non-existent username defaulting to username": {
|
||||||
url: "http://localhost:3000/renders/head/0?scale=2&helm&default=jeb_",
|
url: "http://localhost:3000/renders/head/0?scale=2&helm&default=jeb_",
|
||||||
@ -608,17 +608,17 @@ describe("Crafatar", function() {
|
|||||||
"head render with existing uuid": {
|
"head render with existing uuid": {
|
||||||
url: "http://localhost:3000/renders/head/853c80ef3c3749fdaa49938b674adae6?scale=2",
|
url: "http://localhost:3000/renders/head/853c80ef3c3749fdaa49938b674adae6?scale=2",
|
||||||
etag: '"a846b82963"',
|
etag: '"a846b82963"',
|
||||||
crc32: [353633671, 370672768]
|
crc32: [3487896679]
|
||||||
},
|
},
|
||||||
"head render with non-existent uuid": {
|
"head render with non-existent uuid": {
|
||||||
url: "http://localhost:3000/renders/head/00000000000000000000000000000000?scale=2",
|
url: "http://localhost:3000/renders/head/00000000000000000000000000000000?scale=2",
|
||||||
etag: '"steve"',
|
etag: '"steve"',
|
||||||
crc32: [883439147, 433083528]
|
crc32: [3257141069, 214248305]
|
||||||
},
|
},
|
||||||
"head render with non-existent uuid defaulting to alex": {
|
"head render with non-existent uuid defaulting to alex": {
|
||||||
url: "http://localhost:3000/renders/head/00000000000000000000000000000000?scale=2&default=alex",
|
url: "http://localhost:3000/renders/head/00000000000000000000000000000000?scale=2&default=alex",
|
||||||
etag: '"alex"',
|
etag: '"alex"',
|
||||||
crc32: [1240086237, 1108800327]
|
crc32: [263450586, 3116770561]
|
||||||
},
|
},
|
||||||
"head render with non-existent uuid defaulting to username": {
|
"head render with non-existent uuid defaulting to username": {
|
||||||
url: "http://localhost:3000/renders/head/00000000000000000000000000000000?scale=2&default=jeb_",
|
url: "http://localhost:3000/renders/head/00000000000000000000000000000000?scale=2&default=jeb_",
|
||||||
@ -638,17 +638,17 @@ describe("Crafatar", function() {
|
|||||||
"helm head render with existing uuid": {
|
"helm head render with existing uuid": {
|
||||||
url: "http://localhost:3000/renders/head/853c80ef3c3749fdaa49938b674adae6?scale=2&helm",
|
url: "http://localhost:3000/renders/head/853c80ef3c3749fdaa49938b674adae6?scale=2&helm",
|
||||||
etag: '"a846b82963"',
|
etag: '"a846b82963"',
|
||||||
crc32: [3456497067, 3490318764]
|
crc32: [762377383]
|
||||||
},
|
},
|
||||||
"helm head render with non-existent uuid": {
|
"helm head render with non-existent uuid": {
|
||||||
url: "http://localhost:3000/renders/head/00000000000000000000000000000000?scale=2&helm",
|
url: "http://localhost:3000/renders/head/00000000000000000000000000000000?scale=2&helm",
|
||||||
etag: '"steve"',
|
etag: '"steve"',
|
||||||
crc32: [1858563554, 2647471936]
|
crc32: [3257141069, 214248305]
|
||||||
},
|
},
|
||||||
"helm head render with non-existent uuid defaulting to alex": {
|
"helm head render with non-existent uuid defaulting to alex": {
|
||||||
url: "http://localhost:3000/renders/head/00000000000000000000000000000000?scale=2&helm&default=alex",
|
url: "http://localhost:3000/renders/head/00000000000000000000000000000000?scale=2&helm&default=alex",
|
||||||
etag: '"alex"',
|
etag: '"alex"',
|
||||||
crc32: [2963161105, 1769904825]
|
crc32: [263450586, 3116770561]
|
||||||
},
|
},
|
||||||
"helm head with non-existent uuid defaulting to username": {
|
"helm head with non-existent uuid defaulting to username": {
|
||||||
url: "http://localhost:3000/renders/head/00000000000000000000000000000000?scale=2&helm&default=jeb_",
|
url: "http://localhost:3000/renders/head/00000000000000000000000000000000?scale=2&helm&default=jeb_",
|
||||||
@ -668,17 +668,17 @@ describe("Crafatar", function() {
|
|||||||
"body render with existing username": {
|
"body render with existing username": {
|
||||||
url: "http://localhost:3000/renders/body/jeb_?scale=2",
|
url: "http://localhost:3000/renders/body/jeb_?scale=2",
|
||||||
etag: '"a846b82963"',
|
etag: '"a846b82963"',
|
||||||
crc32: [1291941229, 2628108474]
|
crc32: [3127075871, 2595192206]
|
||||||
},
|
},
|
||||||
"body render with non-existent username": {
|
"body render with non-existent username": {
|
||||||
url: "http://localhost:3000/renders/body/0?scale=2",
|
url: "http://localhost:3000/renders/body/0?scale=2",
|
||||||
etag: '"steve"',
|
etag: '"steve"',
|
||||||
crc32: [2652947188, 2115706574]
|
crc32: [1046655221, 1620063267]
|
||||||
},
|
},
|
||||||
"body render with non-existent username defaulting to alex": {
|
"body render with non-existent username defaulting to alex": {
|
||||||
url: "http://localhost:3000/renders/body/0?scale=2&default=alex",
|
url: "http://localhost:3000/renders/body/0?scale=2&default=alex",
|
||||||
etag: '"alex"',
|
etag: '"alex"',
|
||||||
crc32: [407932087, 2516216042]
|
crc32: [549240598, 3952648540]
|
||||||
},
|
},
|
||||||
"body render with non-existent username defaulting to username": {
|
"body render with non-existent username defaulting to username": {
|
||||||
url: "http://localhost:3000/renders/body/0?scale=2&default=jeb_",
|
url: "http://localhost:3000/renders/body/0?scale=2&default=jeb_",
|
||||||
@ -698,17 +698,17 @@ describe("Crafatar", function() {
|
|||||||
"helm body render with existing username": {
|
"helm body render with existing username": {
|
||||||
url: "http://localhost:3000/renders/body/jeb_?scale=2&helm",
|
url: "http://localhost:3000/renders/body/jeb_?scale=2&helm",
|
||||||
etag: '"a846b82963"',
|
etag: '"a846b82963"',
|
||||||
crc32: [3556188297, 4269754007]
|
crc32: [699892097, 2732138694]
|
||||||
},
|
},
|
||||||
"helm body render with non-existent username": {
|
"helm body render with non-existent username": {
|
||||||
url: "http://localhost:3000/renders/body/0?scale=2&helm",
|
url: "http://localhost:3000/renders/body/0?scale=2&helm",
|
||||||
etag: '"steve"',
|
etag: '"steve"',
|
||||||
crc32: [272191039, 542896675]
|
crc32: [1046655221, 1620063267]
|
||||||
},
|
},
|
||||||
"helm body render with non-existent username defaulting to alex": {
|
"helm body render with non-existent username defaulting to alex": {
|
||||||
url: "http://localhost:3000/renders/body/0?scale=2&helm&default=alex",
|
url: "http://localhost:3000/renders/body/0?scale=2&helm&default=alex",
|
||||||
etag: '"alex"',
|
etag: '"alex"',
|
||||||
crc32: [737759773, 66512449]
|
crc32: [549240598, 3952648540]
|
||||||
},
|
},
|
||||||
"helm body render with non-existent username defaulting to username": {
|
"helm body render with non-existent username defaulting to username": {
|
||||||
url: "http://localhost:3000/renders/body/0?scale=2&helm&default=jeb_",
|
url: "http://localhost:3000/renders/body/0?scale=2&helm&default=jeb_",
|
||||||
@ -728,17 +728,17 @@ describe("Crafatar", function() {
|
|||||||
"body render with existing uuid": {
|
"body render with existing uuid": {
|
||||||
url: "http://localhost:3000/renders/body/853c80ef3c3749fdaa49938b674adae6?scale=2",
|
url: "http://localhost:3000/renders/body/853c80ef3c3749fdaa49938b674adae6?scale=2",
|
||||||
etag: '"a846b82963"',
|
etag: '"a846b82963"',
|
||||||
crc32: [1291941229, 2628108474]
|
crc32: [3127075871]
|
||||||
},
|
},
|
||||||
"body render with non-existent uuid": {
|
"body render with non-existent uuid": {
|
||||||
url: "http://localhost:3000/renders/body/00000000000000000000000000000000?scale=2",
|
url: "http://localhost:3000/renders/body/00000000000000000000000000000000?scale=2",
|
||||||
etag: '"steve"',
|
etag: '"steve"',
|
||||||
crc32: [2652947188, 2115706574]
|
crc32: [1046655221, 1620063267]
|
||||||
},
|
},
|
||||||
"body render with non-existent uuid defaulting to alex": {
|
"body render with non-existent uuid defaulting to alex": {
|
||||||
url: "http://localhost:3000/renders/body/00000000000000000000000000000000?scale=2&default=alex",
|
url: "http://localhost:3000/renders/body/00000000000000000000000000000000?scale=2&default=alex",
|
||||||
etag: '"alex"',
|
etag: '"alex"',
|
||||||
crc32: [407932087, 2516216042]
|
crc32: [549240598, 3952648540]
|
||||||
},
|
},
|
||||||
"body render with non-existent uuid defaulting to username": {
|
"body render with non-existent uuid defaulting to username": {
|
||||||
url: "http://localhost:3000/renders/body/0?scale=2&default=jeb_",
|
url: "http://localhost:3000/renders/body/0?scale=2&default=jeb_",
|
||||||
@ -758,17 +758,17 @@ describe("Crafatar", function() {
|
|||||||
"helm body render with existing uuid": {
|
"helm body render with existing uuid": {
|
||||||
url: "http://localhost:3000/renders/body/853c80ef3c3749fdaa49938b674adae6?scale=2&helm",
|
url: "http://localhost:3000/renders/body/853c80ef3c3749fdaa49938b674adae6?scale=2&helm",
|
||||||
etag: '"a846b82963"',
|
etag: '"a846b82963"',
|
||||||
crc32: [3556188297, 4269754007]
|
crc32: [699892097]
|
||||||
},
|
},
|
||||||
"helm body render with non-existent uuid": {
|
"helm body render with non-existent uuid": {
|
||||||
url: "http://localhost:3000/renders/body/00000000000000000000000000000000?scale=2&helm",
|
url: "http://localhost:3000/renders/body/00000000000000000000000000000000?scale=2&helm",
|
||||||
etag: '"steve"',
|
etag: '"steve"',
|
||||||
crc32: [272191039, 542896675]
|
crc32: [1046655221, 1620063267]
|
||||||
},
|
},
|
||||||
"helm body render with non-existent uuid defaulting to alex": {
|
"helm body render with non-existent uuid defaulting to alex": {
|
||||||
url: "http://localhost:3000/renders/body/00000000000000000000000000000000?scale=2&helm&default=alex",
|
url: "http://localhost:3000/renders/body/00000000000000000000000000000000?scale=2&helm&default=alex",
|
||||||
etag: '"alex"',
|
etag: '"alex"',
|
||||||
crc32: [737759773, 66512449]
|
crc32: [549240598, 3952648540]
|
||||||
},
|
},
|
||||||
"helm body render with non-existent uuid defaulting to url": {
|
"helm body render with non-existent uuid defaulting to url": {
|
||||||
url: "http://localhost:3000/renders/body/00000000000000000000000000000000?scale=2&helm&default=http%3A%2F%2Fexample.com",
|
url: "http://localhost:3000/renders/body/00000000000000000000000000000000?scale=2&helm&default=http%3A%2F%2Fexample.com",
|
||||||
@ -795,7 +795,7 @@ describe("Crafatar", function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
matches = (location.crc32 === crc(body));
|
matches = location.crc32 === crc(body);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
assert.ok(matches);
|
assert.ok(matches);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user