From e0e855b5f49bc8efc3ca69aa83ea28d6becb53cc Mon Sep 17 00:00:00 2001 From: Clement Ho Date: Mon, 9 Jan 2017 16:23:51 -0600 Subject: Fix code review suggestions --- app/assets/javascripts/droplab/droplab_ajax.js | 10 +++++----- app/assets/javascripts/lib/utils/common_utils.js.es6 | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'app') diff --git a/app/assets/javascripts/droplab/droplab_ajax.js b/app/assets/javascripts/droplab/droplab_ajax.js index c8850f121d7..f20610b3811 100644 --- a/app/assets/javascripts/droplab/droplab_ajax.js +++ b/app/assets/javascripts/droplab/droplab_ajax.js @@ -3,6 +3,10 @@ /* global droplab */ require('../window')(function(w){ + function droplabAjaxException(message) { + this.message = message; + } + w.droplabAjax = { _loadUrlData: function _loadUrlData(url) { return new Promise(function(resolve, reject) { @@ -56,11 +60,7 @@ require('../window')(function(w){ } hook.list[config.method].call(hook.list, d); }).catch(function(e) { - if(e.message) { - console.error(e.message, e.stack); // eslint-disable-line no-console - } else { - console.error(e); // eslint-disable-line no-console - } + throw new droplabAjaxException(e.message || e); }); }, diff --git a/app/assets/javascripts/lib/utils/common_utils.js.es6 b/app/assets/javascripts/lib/utils/common_utils.js.es6 index 8aa78f407e5..3e2c75d3cc6 100644 --- a/app/assets/javascripts/lib/utils/common_utils.js.es6 +++ b/app/assets/javascripts/lib/utils/common_utils.js.es6 @@ -169,6 +169,8 @@ w.gl.utils.getParameterByName = (name) => { const url = window.location.href; name = name.replace(/[[\]]/g, '\\$&'); + // Finds the value associated to the name + // Example, state=open where state is the name and open is the value const regex = new RegExp(`[?&]${name}(=([^&#]*)|&|#|$)`); const results = regex.exec(url); if (!results) return null; -- cgit v1.2.3