diff options
author | Clement Ho <ClemMakesApps@gmail.com> | 2016-12-13 06:24:55 +0300 |
---|---|---|
committer | Clement Ho <ClemMakesApps@gmail.com> | 2017-01-10 01:01:23 +0300 |
commit | 49231ccef2fb0bd0cd10d636864d1d50ea70cbdc (patch) | |
tree | 98227fb41d489cd6b7e13cba340301e3806e30c2 /app | |
parent | bcb00bdc487ad0d0e95c4a46a7d9437dcefc4e33 (diff) |
Refactor getUrlParamsArray()
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/filtered_search/filtered_search_manager.js.es6 | 4 | ||||
-rw-r--r-- | app/assets/javascripts/lib/utils/common_utils.js.es6 | 6 |
2 files changed, 7 insertions, 3 deletions
diff --git a/app/assets/javascripts/filtered_search/filtered_search_manager.js.es6 b/app/assets/javascripts/filtered_search/filtered_search_manager.js.es6 index e087d0fd45b..3e57215d608 100644 --- a/app/assets/javascripts/filtered_search/filtered_search_manager.js.es6 +++ b/app/assets/javascripts/filtered_search/filtered_search_manager.js.es6 @@ -80,9 +80,7 @@ } loadSearchParamsFromURL() { - // We can trust that each param has one & since values containing & will be encoded - // Remove the first character of search as it is always ? - const params = window.location.search.slice(1).split('&'); + const params = gl.utils.getUrlParamsArray(); let inputValues = []; params.forEach((p) => { diff --git a/app/assets/javascripts/lib/utils/common_utils.js.es6 b/app/assets/javascripts/lib/utils/common_utils.js.es6 index f0186c1390f..7a18f760e1b 100644 --- a/app/assets/javascripts/lib/utils/common_utils.js.es6 +++ b/app/assets/javascripts/lib/utils/common_utils.js.es6 @@ -124,6 +124,12 @@ return parsedUrl.pathname.charAt(0) === '/' ? parsedUrl.pathname : '/' + parsedUrl.pathname; }; + gl.utils.getUrlParamsArray = function () { + // We can trust that each param has one & since values containing & will be encoded + // Remove the first character of search as it is always ? + return window.location.search.slice(1).split('&'); + } + gl.utils.getParameterByName = function(name) { var url = window.location.href; var param = name.replace(/[[\]]/g, '\\$&'); |