summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/lib
diff options
context:
space:
mode:
authorRegis <boudinot.regis@yahoo.com>2017-01-06 15:27:56 -0700
committerRegis <boudinot.regis@yahoo.com>2017-01-06 15:27:56 -0700
commitce996962d6bec0d29664ac3dbe62dcd18630230e (patch)
treeabdf0040eae1959db3781da44cc25e3ec0c071a5 /app/assets/javascripts/lib
parent45b51e712b3848818515cccb1341afce3815fbd6 (diff)
downloadgitlab-ce-ce996962d6bec0d29664ac3dbe62dcd18630230e.tar.gz
add param_helper to utils - fix switch statement in pagination
Diffstat (limited to 'app/assets/javascripts/lib')
-rw-r--r--app/assets/javascripts/lib/utils/param_helper.js.es618
1 files changed, 18 insertions, 0 deletions
diff --git a/app/assets/javascripts/lib/utils/param_helper.js.es6 b/app/assets/javascripts/lib/utils/param_helper.js.es6
new file mode 100644
index 00000000000..2b150c415c8
--- /dev/null
+++ b/app/assets/javascripts/lib/utils/param_helper.js.es6
@@ -0,0 +1,18 @@
+/* eslint-disable no-param-reassign */
+
+((w) => {
+ /**
+ 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.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 = {}));