From 649297df8341e77d738b1b95599f3c3f9d6ba231 Mon Sep 17 00:00:00 2001 From: IagoLast Date: Wed, 13 Jun 2018 09:42:53 +0200 Subject: [PATCH] Use early return --- lib/cartodb/utils/date-wrapper.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/cartodb/utils/date-wrapper.js b/lib/cartodb/utils/date-wrapper.js index 60e88001..9d5657b1 100644 --- a/lib/cartodb/utils/date-wrapper.js +++ b/lib/cartodb/utils/date-wrapper.js @@ -38,21 +38,22 @@ function getColumnsWithWrappedDates(query) { if(!query){ return; } - if (query.match(/\b_cdb_epoch_transformation\b/)) { - const columns = []; - const fieldMatcher = /\bdate_part\('epoch', "([^"]+)"\) as "([^"]+)"/gmi; - let match; - do { - match = fieldMatcher.exec(query); - if (match && match[1] === match[2]) { - columns.push(match[1]); - } - } while (match); - return columns; + if (!query.match(/\b_cdb_epoch_transformation\b/)) { + return; } + const columns = []; + const fieldMatcher = /\bdate_part\('epoch', "([^"]+)"\) as "([^"]+)"/gmi; + let match; + do { + match = fieldMatcher.exec(query); + if (match && match[1] === match[2]) { + columns.push(match[1]); + } + } while (match); + return columns; } module.exports = { wrapDates, getColumnsWithWrappedDates -}; \ No newline at end of file +};