summaryrefslogtreecommitdiff
path: root/app/controllers/concerns/routable_actions.rb
diff options
context:
space:
mode:
authorMichael Kozono <mkozono@gmail.com>2017-05-01 13:46:30 -0700
committerMichael Kozono <mkozono@gmail.com>2017-05-05 12:11:57 -0700
commit7d02bcd2e0165a90a9f2c1edb34b064ff76afd69 (patch)
tree3b74cbbf74fca3b36effa5ea4b33d8bd29e22f73 /app/controllers/concerns/routable_actions.rb
parentf4a2dfb46f168d3fd7309aca8631cf680456fa82 (diff)
downloadgitlab-ce-7d02bcd2e0165a90a9f2c1edb34b064ff76afd69.tar.gz
Redirect from redirect routes to canonical routes
Diffstat (limited to 'app/controllers/concerns/routable_actions.rb')
-rw-r--r--app/controllers/concerns/routable_actions.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/app/controllers/concerns/routable_actions.rb b/app/controllers/concerns/routable_actions.rb
new file mode 100644
index 00000000000..6f16377a156
--- /dev/null
+++ b/app/controllers/concerns/routable_actions.rb
@@ -0,0 +1,11 @@
+module RoutableActions
+ extend ActiveSupport::Concern
+
+ def ensure_canonical_path(routable, requested_path)
+ return unless request.get?
+
+ if routable.full_path != requested_path
+ redirect_to request.original_url.sub(requested_path, routable.full_path)
+ end
+ end
+end