From 153afd0cd4e2f5cad7d13cb489fbaa5854ff6b0c Mon Sep 17 00:00:00 2001
From: Alfredo Sumaran <alfredo@gitlab.com>
Date: Mon, 11 Apr 2016 16:10:00 -0500
Subject: [PATCH] Reutilize existing method to update param value

---
 app/assets/javascripts/todos.js.coffee | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/app/assets/javascripts/todos.js.coffee b/app/assets/javascripts/todos.js.coffee
index f16b735ece0..37b4d2f66c7 100644
--- a/app/assets/javascripts/todos.js.coffee
+++ b/app/assets/javascripts/todos.js.coffee
@@ -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
-- 
GitLab