support redirection for capes

This commit is contained in:
jomo 2015-04-25 22:59:33 +02:00
parent 5c53694f9d
commit 4286b35775
2 changed files with 2 additions and 8 deletions

View File

@ -5,6 +5,7 @@ var cache = require("../cache");
// GET cape request // GET cape request
module.exports = function(req, callback) { module.exports = function(req, callback) {
var userId = (req.url.pathname.split("/")[2] || "").split(".")[0]; var userId = (req.url.pathname.split("/")[2] || "").split(".")[0];
var def = req.url.query.default;
var rid = req.id; var rid = req.id;
if (!helpers.id_valid(userId)) { if (!helpers.id_valid(userId)) {
@ -31,6 +32,7 @@ module.exports = function(req, callback) {
status: status, status: status,
body: image, body: image,
type: image ? "image/png" : undefined, type: image ? "image/png" : undefined,
redirect: image ? undefined : def,
hash: hash, hash: hash,
err: err err: err
}); });

View File

@ -381,10 +381,6 @@ describe("Crafatar", function() {
url: "http://localhost:3000/capes/0", url: "http://localhost:3000/capes/0",
crc32: 0 crc32: 0
}, },
"cape with not existing username defaulting to alex": {
url: "http://localhost:3000/capes/0?default=alex",
crc32: 0
},
"cape with not existing username defaulting to url": { "cape with not existing username defaulting to url": {
url: "http://localhost:3000/capes/0?default=http://example.com", url: "http://localhost:3000/capes/0?default=http://example.com",
crc32: 0, crc32: 0,
@ -399,10 +395,6 @@ describe("Crafatar", function() {
url: "http://localhost:3000/capes/00000000000000000000000000000000", url: "http://localhost:3000/capes/00000000000000000000000000000000",
crc32: 0 crc32: 0
}, },
"cape with not existing uuid defaulting to alex": {
url: "http://localhost:3000/capes/00000000000000000000000000000000?default=alex",
crc32: 0
},
"cape with not existing uuid defaulting to url": { "cape with not existing uuid defaulting to url": {
url: "http://localhost:3000/capes/00000000000000000000000000000000?default=http://example.com", url: "http://localhost:3000/capes/00000000000000000000000000000000?default=http://example.com",
crc32: 0, crc32: 0,