From 13b66c4e3820cf5117aa1cd1f53ddf19099c2045 Mon Sep 17 00:00:00 2001 From: Simon Tokumine Date: Tue, 8 May 2012 10:38:01 +0100 Subject: [PATCH] check for nulls --- lib/cartodb/cache_validator.js | 3 ++- test/acceptance/cache_validator.js | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/cartodb/cache_validator.js b/lib/cartodb/cache_validator.js index ac6cedcc..30cbb601 100644 --- a/lib/cartodb/cache_validator.js +++ b/lib/cartodb/cache_validator.js @@ -39,7 +39,8 @@ function generateCacheChannel(req, callback){ callback(channelCache[sql_md5]); } else{ // strip out windshaft/mapnik inserted sql - var sql = req.params.sql.match(/^\((.*)\)\sas\scdbq$/)[1]; + var sql = req.params.sql.match(/^\((.*)\)\sas\scdbq$/); + sql = (sql != null) ? sql[1] : req.params.sql; // build up api string var sqlapi = api.protocol + '://' + username + '.' + api.host + ':' + api.port + '/api/' + api.version + '/sql' diff --git a/test/acceptance/cache_validator.js b/test/acceptance/cache_validator.js index 6e39dd8a..2429725d 100644 --- a/test/acceptance/cache_validator.js +++ b/test/acceptance/cache_validator.js @@ -28,8 +28,8 @@ tests['working'] = function() { assert.ok(true); }; tests['should call purge on varnish when invalidate database'] = function() { var varnish = new VarnishEmu(function(cmds) { assert.ok(cmds.length == 1); - assert.equal('purge obj.http.X-Cache-Channel == test_cache\n', cmds[0]); + assert.equal('purge obj.http.X-Cache-Channel == test_db:test_cache\n', cmds[0]); }); CacheValidator.init('localhost', 1337); - CacheValidator.invalidate_db('test_cache'); + CacheValidator.invalidate_db('test_db', 'test_cache'); }