Class: Gitlab::Routing::LegacyRedirector
- Inherits:
-
Object
- Object
- Gitlab::Routing::LegacyRedirector
- Defined in:
- lib/gitlab/routing.rb
Instance Method Summary collapse
Constructor Details
#initialize(path_type) ⇒ LegacyRedirector
10 11 12 |
# File 'lib/gitlab/routing.rb', line 10 def initialize(path_type) @path_type = path_type end |
Instance Method Details
#call(_params, request) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/gitlab/routing.rb', line 14 def call(_params, request) ensure_valid_uri!(request) # Only replace the last occurrence of `path`. # # `request.fullpath` includes the querystring new_path = request.path.sub(%r{/#{@path_type}(/*)(?!.*#{@path_type})}, "/-/#{@path_type}\\1") new_path = "#{new_path}?#{request.query_string}" if request.query_string.present? new_path end |