Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArinde Eniola <eniolaarinde1@gmail.com>2016-04-17 01:30:31 +0300
committerArinde Eniola <eniolaarinde1@gmail.com>2016-04-17 01:30:31 +0300
commit259970ca1b3118f3eb71751b33a3a53ff4a1fa59 (patch)
treea7f6f8fd2ff41d5398c202dbe3397cb784a71aac /app/assets/javascripts/lib
parentef9f5579d29ac4b72f463fabc6e0ace10078c009 (diff)
abstract code for removing or getting a param query string from url
Diffstat (limited to 'app/assets/javascripts/lib')
-rw-r--r--app/assets/javascripts/lib/url_utility.js.coffee16
1 files changed, 16 insertions, 0 deletions
diff --git a/app/assets/javascripts/lib/url_utility.js.coffee b/app/assets/javascripts/lib/url_utility.js.coffee
index abd556e0b4e..c2e3c807e5e 100644
--- a/app/assets/javascripts/lib/url_utility.js.coffee
+++ b/app/assets/javascripts/lib/url_utility.js.coffee
@@ -28,4 +28,20 @@
newUrl = "#{newUrl}#{(if newUrl.indexOf('?') > 0 then '&' else '?')}#{paramName}=#{paramValue}"
newUrl
+ # get parameter query string from url.
+ w.gl.utils.getParamQueryString = (param) ->
+ pageURL = decodeURIComponent(window.location.search.substring(1))
+ urlVariables = pageURL.split('&')
+ (
+ variables for variables in urlVariables when variables.indexOf(param) > -1
+ ).join('&')
+
+ # removes parameter query string from url. returns the modified url
+ w.gl.utils.removeParamQueryString = (url, param) ->
+ url = decodeURIComponent(url)
+ urlVariables = url.split('&')
+ (
+ variables for variables in urlVariables when variables.indexOf(param) is -1
+ ).join('&')
+
) window