mirror of
https://github.com/azures04/crafatar.git
synced 2026-03-22 16:01:16 +01:00
support redirection for capes
This commit is contained in:
parent
5c53694f9d
commit
4286b35775
@ -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
|
||||||
});
|
});
|
||||||
|
|||||||
@ -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,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user