More sanity checking on passed IDs

This commit is contained in:
Jonathan Cremin 2014-12-05 18:08:40 +00:00
parent a33570e1d0
commit ff698cff14
4 changed files with 22 additions and 2 deletions
lib/services

View file

@ -25,6 +25,12 @@ module.exports.lookupId = function(id) {
method: 'getObjectFromShortCode',
short_code: id,
}, function(err, results) {
if (err || !JSON.parse(results).result) {
var error = new Error("Not Found");
error.status = 404;
deferred.reject(error);
return;
}
var result = JSON.parse(results).result;
var parsed = parse(result.shortUrl)
var id = parsed.path.replace("/x/", "").replace("/", "");