diff options
author | Regis <boudinot.regis@yahoo.com> | 2017-01-09 10:26:43 -0700 |
---|---|---|
committer | Regis <boudinot.regis@yahoo.com> | 2017-01-09 10:26:43 -0700 |
commit | 55df55367f68ca0d1df2ad13363c98ec62fc3930 (patch) | |
tree | 1dca3bea8ffa991fcfa0dc14a1dd24ac27198c6c | |
parent | 5498448535c74e326dcb9a714dc3d8992c965f2c (diff) | |
download | gitlab-ce-55df55367f68ca0d1df2ad13363c98ec62fc3930.tar.gz |
move param helper to common utils
-rw-r--r-- | app/assets/javascripts/lib/utils/common_utils.js.es6 (renamed from app/assets/javascripts/lib/utils/common_utils.js) | 15 | ||||
-rw-r--r-- | app/assets/javascripts/lib/utils/param_helper.js.es6 | 21 | ||||
-rw-r--r-- | app/assets/javascripts/vue_pagination/index.js.es6 | 2 | ||||
-rw-r--r-- | spec/javascripts/vue_pagination/pagination_spec.js.es6 | 1 |
4 files changed, 16 insertions, 23 deletions
diff --git a/app/assets/javascripts/lib/utils/common_utils.js b/app/assets/javascripts/lib/utils/common_utils.js.es6 index 31a71379af3..b8d637a9827 100644 --- a/app/assets/javascripts/lib/utils/common_utils.js +++ b/app/assets/javascripts/lib/utils/common_utils.js.es6 @@ -139,6 +139,21 @@ }, 200); }; + /** + this will take in the `name` of the param you want to parse in the url + if the name does not exist this function will return `null` + otherwise it will return the value of the param key provided + */ + w.gl.utils.getParameterByName = (name) => { + const url = window.location.href; + name = name.replace(/[[\]]/g, '\\$&'); + const regex = new RegExp(`[?&]${name}(=([^&#]*)|&|#|$)`); + const results = regex.exec(url); + if (!results) return null; + if (!results[2]) return ''; + return decodeURIComponent(results[2].replace(/\+/g, ' ')); + }; + })(window); }).call(this); diff --git a/app/assets/javascripts/lib/utils/param_helper.js.es6 b/app/assets/javascripts/lib/utils/param_helper.js.es6 deleted file mode 100644 index 01b3a2ee07f..00000000000 --- a/app/assets/javascripts/lib/utils/param_helper.js.es6 +++ /dev/null @@ -1,21 +0,0 @@ -/* eslint-disable no-param-reassign */ - -((gl) => { - gl.utils = gl.utils || (gl.utils = {}); - - /** - this will take in the `name` of the param you want to parse in the url - if the name does not exist this function will return `null` - otherwise it will return the value of the param key provided - */ - - gl.utils.getParameterByName = (name) => { - const url = window.location.href; - name = name.replace(/[[\]]/g, '\\$&'); - const regex = new RegExp(`[?&]${name}(=([^&#]*)|&|#|$)`); - const results = regex.exec(url); - if (!results) return null; - if (!results[2]) return ''; - return decodeURIComponent(results[2].replace(/\+/g, ' ')); - }; -})(window.gl || (window.gl = {})); diff --git a/app/assets/javascripts/vue_pagination/index.js.es6 b/app/assets/javascripts/vue_pagination/index.js.es6 index 78a26f65dfd..605824fa939 100644 --- a/app/assets/javascripts/vue_pagination/index.js.es6 +++ b/app/assets/javascripts/vue_pagination/index.js.es6 @@ -1,8 +1,6 @@ /* global Vue, gl */ /* eslint-disable no-param-reassign, no-plusplus */ -/*= require lib/utils/param_helper.js.es6 */ - ((gl) => { const PAGINATION_UI_BUTTON_LIMIT = 4; const UI_LIMIT = 6; diff --git a/spec/javascripts/vue_pagination/pagination_spec.js.es6 b/spec/javascripts/vue_pagination/pagination_spec.js.es6 index c5f70ba5bfb..ca13d66282a 100644 --- a/spec/javascripts/vue_pagination/pagination_spec.js.es6 +++ b/spec/javascripts/vue_pagination/pagination_spec.js.es6 @@ -1,4 +1,5 @@ //= require vue +//= require lib/utils/common_utils //= require vue_pagination/index describe('Pagination component', () => { |