From 3f6afb4530d6f7ad2b2c12befb2cb6aaed3b04ab Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 26 Sep 2017 14:56:20 +0200 Subject: [PATCH] validation middleware for layer route (conflicting route) --- lib/cartodb/controllers/layergroup.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/cartodb/controllers/layergroup.js b/lib/cartodb/controllers/layergroup.js index 8af1f619..2172f6c3 100644 --- a/lib/cartodb/controllers/layergroup.js +++ b/lib/cartodb/controllers/layergroup.js @@ -71,6 +71,7 @@ LayergroupController.prototype.register = function(router) { router.get( '/:token/:layer/:z/:x/:y.(:format)', + validateLayerRouteMiddleware, this.prepareContext, this.layer.bind(this) ); @@ -249,9 +250,6 @@ LayergroupController.prototype.tile = function(req, res, next) { // Gets a tile for a given token, layer set of tile ZXY coords. (OSM style) LayergroupController.prototype.layer = function(req, res, next) { - if (req.params.token === 'static') { - return next(); - } req.profiler.start('windshaft.maplayer_tile'); this.tileOrLayer(req, res, next); }; @@ -462,3 +460,12 @@ LayergroupController.prototype.getAffectedTables = function(user, dbName, layerg callback ); }; + + +function validateLayerRouteMiddleware(req, res, next) { + if (req.params.token === 'static') { + return next('route'); + } + + next(); +} \ No newline at end of file