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:
authorSean McGivern <sean@gitlab.com>2017-11-16 20:12:45 +0300
committerSean McGivern <sean@gitlab.com>2017-11-16 20:13:40 +0300
commit9f921b73f2796554f79a8b730999ac884daf4a19 (patch)
tree22cc9cabd35bc1f8b04b9c9228900632f1bb3a07 /lib/gitlab/routing.rb
parentc5720382e67b18258c71d717c0e8073cc322b308 (diff)
Don't add a trailing slash in group redirects
Because we ignored the format, a request to `/groups/foo/labels.json` would redirect to `/groups/foo/-/labels/.json`. But really, it's worse than that, because unless the request contained a trailing slash, we shouldn't add one. Now, we only _keep_ a trailing slash, but don't _add_ one.
Diffstat (limited to 'lib/gitlab/routing.rb')
-rw-r--r--lib/gitlab/routing.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/gitlab/routing.rb b/lib/gitlab/routing.rb
index 910533076b0..2c994536060 100644
--- a/lib/gitlab/routing.rb
+++ b/lib/gitlab/routing.rb
@@ -46,10 +46,10 @@ module Gitlab
# Only replace the last occurence of `path`.
#
# `request.fullpath` includes the querystring
- path = request.path.sub(%r{/#{path}/*(?!.*#{path})}, "/-/#{path}/")
- path << "?#{request.query_string}" if request.query_string.present?
+ new_path = request.path.sub(%r{/#{path}(/*)(?!.*#{path})}, "/-/#{path}\\1")
+ new_path << "?#{request.query_string}" if request.query_string.present?
- path
+ new_path
end
paths.each do |path|