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 /app/assets/javascripts/lib/utils | |
parent | 5498448535c74e326dcb9a714dc3d8992c965f2c (diff) | |
download | gitlab-ce-55df55367f68ca0d1df2ad13363c98ec62fc3930.tar.gz |
move param helper to common utils
Diffstat (limited to 'app/assets/javascripts/lib/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 |
2 files changed, 15 insertions, 21 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 = {})); |