Windshaft-cartodb/lib/cartodb/api/middlewares/check-static-image-format.js

12 lines
380 B
JavaScript
Raw Normal View History

2018-05-11 23:41:00 +08:00
const VALID_IMAGE_FORMATS = ['png', 'jpg', 'jpeg'];
module.exports = function checkStaticImageFormat () {
return function checkStaticImageFormatMiddleware (req, res, next) {
if(!VALID_IMAGE_FORMATS.includes(req.params.format.toLowerCase())) {
return next(new Error(`Unsupported image format "${req.params.format}"`));
}
next();
};
};