diff options
author | Arinde Eniola <eniolaarinde1@gmail.com> | 2016-04-16 23:30:31 +0100 |
---|---|---|
committer | Arinde Eniola <eniolaarinde1@gmail.com> | 2016-04-16 23:30:31 +0100 |
commit | 259970ca1b3118f3eb71751b33a3a53ff4a1fa59 (patch) | |
tree | a7f6f8fd2ff41d5398c202dbe3397cb784a71aac /app/assets/javascripts/lib | |
parent | ef9f5579d29ac4b72f463fabc6e0ace10078c009 (diff) | |
download | gitlab-ce-259970ca1b3118f3eb71751b33a3a53ff4a1fa59.tar.gz |
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.coffee | 16 |
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 |