Browse Source

allow dashed uuid

jomo 10 years ago
parent
commit
3216833887
2 changed files with 6 additions and 3 deletions
  1. 2 1
      modules/helpers.js
  2. 4 2
      routes/avatars.js

+ 2 - 1
modules/helpers.js

@@ -3,7 +3,8 @@ var config = require('./config');
 var cache = require('./cache');
 var skins = require('./skins');
 
-var valid_uuid = /^([0-9a-f]{32}|[a-zA-Z0-9_]{1,16})$/; // uuid|username
+// 0098cb60-fa8e-427c-b299-793cbd302c9a
+var valid_uuid = /^([0-9a-f-]{32,36}|[a-zA-Z0-9_]{1,16})$/; // uuid|username
 var hash_pattern = /([^\/]+)(?=\.\w{0,16}$)|((?:[a-z][a-z]*[0-9]+[a-z0-9]*))/;
 
 function get_hash(url) {

+ 4 - 2
routes/avatars.js

@@ -2,7 +2,6 @@ var helpers = require('../modules/helpers');
 var router = require('express').Router();
 var config = require('../modules/config');
 var skins = require('../modules/skins');
-var networking = require('../modules/networking')
 
 var human_status = {
   0: "none",
@@ -19,7 +18,7 @@ router.get('/:uuid.:ext?', function(req, res) {
   var def = req.query.default;
   var helm = req.query.hasOwnProperty('helm');
   var start = new Date();
-  
+
   // Prevent app from crashing/freezing
   if (size < config.min_size || size > config.max_size) {
     // "Unprocessable Entity", valid request, but semantically erroneous:
@@ -31,6 +30,9 @@ router.get('/:uuid.:ext?', function(req, res) {
     return;
   }
 
+  // strip dashes
+  uuid = uuid.replace(/-/g, "");
+
   try {
     helpers.get_avatar(uuid, helm, size, function(err, status, image) {
       console.log(uuid + " - " + human_status[status]);