Skip to content
Snippets Groups Projects
Commit 153afd0c authored by Alfredo Sumaran's avatar Alfredo Sumaran
Browse files

Reutilize existing method to update param value

parent fe276d0d
No related branches found
No related tags found
2 merge requests!4779Test/#123 Master,!3428Refresh page according remaining todos
Pipeline #
Loading
Loading
@@ -93,21 +93,12 @@ class @Todos
if newPages isnt currPages
# Redirect to previous page if there's one available
if currPages > 1 and currPage is currPages
url = @updateQueryStringParameter(url, 'page', currPages - 1)
pageParams =
page: currPages - 1
url = gl.utils.mergeUrlParams(pageParams, url)
 
location.replace url
 
updateQueryStringParameter: (uri, key, value) ->
separator = if uri.indexOf('?') isnt -1 then '&' else '?'
# Matches key and value
regex = new RegExp('([?&])' + key + '=.*?(&|#|$)', 'i')
if uri.match(regex)
return uri.replace(regex, '$1' + key + '=' + value + '$2')
uri + separator + key + '=' + value
goToTodoUrl: (e)->
todoLink = $(this).data('url')
if e.metaKey
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment