Commit 3cbfb1ee7c28c0171bc4c584ce3c852b07f8521a

Authored by Dmitriy Zaporozhets
1 parent 55327823

Remove .git from project url end redirect

Ex. redirect from
  localhost/group/project.git
to
  localhost/group/project

It used to prevent 404 error when follow submodule http link
like http://localhost/group/project.git
Showing 1 changed file with 9 additions and 0 deletions   Show diff stats
app/controllers/application_controller.rb
... ... @@ -63,6 +63,15 @@ class ApplicationController < ActionController::Base
63 63 def project
64 64 id = params[:project_id] || params[:id]
65 65  
  66 + # Redirect from
  67 + # localhost/group/project.git
  68 + # to
  69 + # localhost/group/project
  70 + #
  71 + if id =~ /\.git\Z/
  72 + redirect_to request.original_url.gsub(/\.git\Z/, '') and return
  73 + end
  74 +
66 75 @project = Project.find_with_namespace(id)
67 76  
68 77 if @project and can?(current_user, :read_project, @project)
... ...