diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-10-26 17:06:51 +0300 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-11-07 21:52:09 +0300 |
commit | 414c4e3fd83a6a3cae623dcc8135d6ef09a30562 (patch) | |
tree | d084e53e0cc2bcfe994987511a8759068d002db2 /lib | |
parent | 3a8cf27674341e345bcbb823506f350849178ed7 (diff) |
Add helper methods to redirect legacy paths
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/routing.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/gitlab/routing.rb b/lib/gitlab/routing.rb index e57890f1143..abfd413b7ea 100644 --- a/lib/gitlab/routing.rb +++ b/lib/gitlab/routing.rb @@ -40,5 +40,14 @@ module Gitlab def self.url_helpers @url_helpers ||= Gitlab::Application.routes.url_helpers end + + def self.redirect_legacy_paths(router, *paths) + paths.each do |path| + router.match "/#{path}(/*rest)", + via: [:get, :post, :patch, :delete], + to: router.redirect { |_params, request| request.fullpath.gsub(%r{/#{path}/*}, "/-/#{path}/") }, + as: "legacy_#{path}_redirect" + end + end end end |