From c1c6d493b728484c82e963df335d224e1ff80657 Mon Sep 17 00:00:00 2001 From: javi Date: Wed, 18 Mar 2015 15:54:05 +0100 Subject: [PATCH] allow urls like /u/:user/ --- config/environments/development.js.example | 4 ++-- config/environments/production.js.example | 4 ++-- config/environments/staging.js.example | 4 ++-- lib/cartodb/server_options.js | 3 +++ 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/config/environments/development.js.example b/config/environments/development.js.example index 1c036f67..4757f7d8 100644 --- a/config/environments/development.js.example +++ b/config/environments/development.js.example @@ -14,11 +14,11 @@ var config = { // Base url for the Templated Maps API // "/api/v1/map/named" is the new API, // "/tiles/template" is for compatibility with versions up to 1.6.x - ,base_url_templated: '(?:/api/v1/map/named|/tiles/template)' + ,base_url_templated: '(?:/api/v1/map/named|/tiles/template|/u/:user/api/v1/map/named)' // Base url for the Detached Maps API // "maps" is the the new API, // "tiles/layergroup" is for compatibility with versions up to 1.6.x - ,base_url_detached: '(?:/api/v1/map|/tiles/layergroup)' + ,base_url_detached: '(?:/api/v1/map|/tiles/layergroup|/u/:user/api/v1/map)' // Base url for the Inline Maps and Table Maps API ,base_url_legacy: '/tiles/:table' diff --git a/config/environments/production.js.example b/config/environments/production.js.example index 28f2ee95..2aaf6d60 100644 --- a/config/environments/production.js.example +++ b/config/environments/production.js.example @@ -14,11 +14,11 @@ var config = { // Base url for the Templated Maps API // "/api/v1/map/named" is the new API, // "/tiles/template" is for compatibility with versions up to 1.6.x - ,base_url_templated: '(?:/api/v1/map/named|/tiles/template)' + ,base_url_templated: '(?:/api/v1/map/named|/tiles/template|/u/:user/api/v1/map/named)' // Base url for the Detached Maps API // "maps" is the the new API, // "tiles/layergroup" is for compatibility with versions up to 1.6.x - ,base_url_detached: '(?:/api/v1/map|/tiles/layergroup)' + ,base_url_detached: '(?:/api/v1/map|/tiles/layergroup|/u/:user/api/v1/map)' // Base url for the Inline Maps and Table Maps API ,base_url_legacy: '/tiles/:table' diff --git a/config/environments/staging.js.example b/config/environments/staging.js.example index 88a0d8e7..77da9151 100644 --- a/config/environments/staging.js.example +++ b/config/environments/staging.js.example @@ -14,11 +14,11 @@ var config = { // Base url for the Templated Maps API // "/api/v1/maps/named" is the new API, // "/tiles/template" is for compatibility with versions up to 1.6.x - ,base_url_templated: '(?:/api/v1/maps/named|/tiles/template)' + ,base_url_templated: '(?:/api/v1/map/named|/tiles/template|/u/:user/api/v1/map/named)' // Base url for the Detached Maps API // "/api/v1/maps" is the the new API, // "/tiles/layergroup" is for compatibility with versions up to 1.6.x - ,base_url_detached: '(?:/api/v1/maps|/tiles/layergroup)' + ,base_url_detached: '(?:/api/v1/map|/tiles/layergroup|/u/:user/api/v1/map)' // Base url for the Inline Maps and Table Maps API ,base_url_legacy: '/tiles/:table' diff --git a/lib/cartodb/server_options.js b/lib/cartodb/server_options.js index ff052586..951f2d7f 100644 --- a/lib/cartodb/server_options.js +++ b/lib/cartodb/server_options.js @@ -377,6 +377,9 @@ module.exports = function(redisPool) { me.userByReq = function(req) { var host = req.headers.host; + if (req.params.user) { + return req.params.user; + } var mat = host.match(this.re_userFromHost); if ( ! mat ) { console.error("ERROR: user pattern '" + this.re_userFromHost + "' does not match hostname '" + host + "'");