Merge branch 'git_to_html_redirection' into 'master'

Redirect http://someproject.git to http://someproject

Closes #26275

See merge request !8951
This commit is contained in:
Sean McGivern 2017-02-03 21:06:02 +00:00
commit b7685ad113
3 changed files with 16 additions and 1 deletions

View file

@ -18,7 +18,7 @@ class Projects::ApplicationController < ApplicationController
# to
# localhost/group/project
#
if id =~ /\.git\Z/
if params[:format] == 'git'
redirect_to request.original_url.gsub(/\.git\/?\Z/, '')
return
end

View file

@ -0,0 +1,4 @@
---
title: Redirect http://someproject.git to http://someproject
merge_request:
author: blackst0ne

View file

@ -213,6 +213,17 @@ describe ProjectsController do
expect(response.status).to eq 404
end
end
context "redirection from http://someproject.git" do
it 'redirects to project page (format.html)' do
project = create(:project, :public)
get :show, namespace_id: project.namespace.path, id: project.path, format: :git
expect(response).to have_http_status(302)
expect(response).to redirect_to(namespace_project_path)
end
end
end
describe "#update" do