diff options
| author | Sean McGivern <sean@gitlab.com> | 2017-11-16 17:12:45 +0000 |
|---|---|---|
| committer | Sean McGivern <sean@gitlab.com> | 2017-11-16 17:13:40 +0000 |
| commit | 9f921b73f2796554f79a8b730999ac884daf4a19 (patch) | |
| tree | 22cc9cabd35bc1f8b04b9c9228900632f1bb3a07 /lib | |
| parent | c5720382e67b18258c71d717c0e8073cc322b308 (diff) | |
| download | gitlab-ce-9f921b73f2796554f79a8b730999ac884daf4a19.tar.gz | |
Don't add a trailing slash in group redirects40230-groups-gitlab-org-labels-json-redirects-to-groups-gitlab-org-labels-json
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')
| -rw-r--r-- | lib/gitlab/routing.rb | 6 |
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| |
