Procházet zdrojové kódy

support redirection for capes

jomo před 10 roky
rodič
revize
4286b35775
2 změnil soubory, kde provedl 2 přidání a 8 odebrání
  1. 2 0
      lib/routes/capes.js
  2. 0 8
      test/test.js

+ 2 - 0
lib/routes/capes.js

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

+ 0 - 8
test/test.js

@@ -381,10 +381,6 @@ describe("Crafatar", function() {
         url: "http://localhost:3000/capes/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": {
         url: "http://localhost:3000/capes/0?default=http://example.com",
         crc32: 0,
@@ -399,10 +395,6 @@ describe("Crafatar", function() {
         url: "http://localhost:3000/capes/00000000000000000000000000000000",
         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": {
         url: "http://localhost:3000/capes/00000000000000000000000000000000?default=http://example.com",
         crc32: 0,