diff --git a/lib/cartodb/api/map/tile-layergroup-controller.js b/lib/cartodb/api/map/tile-layergroup-controller.js index 229f5d00..311fec45 100644 --- a/lib/cartodb/api/map/tile-layergroup-controller.js +++ b/lib/cartodb/api/map/tile-layergroup-controller.js @@ -42,12 +42,15 @@ module.exports = class TileLayergroupController { } register (mapRouter) { - // REGEXP doesn't match with `val` + // REGEXP: doesn't match with `val` const not = (val) => `(?!${val})([^\/]+?)`; + // Sadly the path that matches 1 also matches with 2 so we need to tell to express + // that performs only the middlewares of the first path that matches + // for that we use one array to group all paths. mapRouter.get([ - `/:token/:z/:x/:y@:scale_factor?x.:format`, - `/:token/:z/:x/:y.:format`, + `/:token/:z/:x/:y@:scale_factor?x.:format`, // 1 + `/:token/:z/:x/:y.:format`, // 2 `/:token${not('static')}/:layer/:z/:x/:y.(:format)` ], this.middlewares()); }