diff options
| author | Robert Speicher <robert@gitlab.com> | 2015-10-22 13:03:04 +0000 |
|---|---|---|
| committer | Robert Speicher <robert@gitlab.com> | 2015-10-22 13:03:04 +0000 |
| commit | 7924dd5c9f5d55daaa49132844e71d28169d0e20 (patch) | |
| tree | 09b09ba4e2948662f4250714e4734aaaf9b20201 /app | |
| parent | b97977afef26e8aaad9228c8c7dffecdbe1a8e59 (diff) | |
| parent | 98f982f91d6e2d6ec1b59ea5645d8320989e2de6 (diff) | |
| download | gitlab-ce-7924dd5c9f5d55daaa49132844e71d28169d0e20.tar.gz | |
Merge branch 'project-path-case-sensitivity' into 'master'
Prefer project with exact path to differently cased one when both exist.
Fixes #3113.
See merge request !1649
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/application_controller.rb | 1 | ||||
| -rw-r--r-- | app/models/project.rb | 9 |
2 files changed, 5 insertions, 5 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 865deb7d46a..1b0609e279e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -124,7 +124,6 @@ class ApplicationController < ActionController::Base project_path = "#{namespace}/#{id}" @project = Project.find_with_namespace(project_path) - if @project and can?(current_user, :read_project, @project) if @project.path_with_namespace != project_path redirect_to request.original_url.gsub(project_path, @project.path_with_namespace) and return diff --git a/app/models/project.rb b/app/models/project.rb index 4c5bf220f24..74b89aad499 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -243,11 +243,12 @@ class Project < ActiveRecord::Base # Use of unscoped ensures we're not secretly adding any ORDER BYs, which # have a negative impact on performance (and aren't needed for this # query). - unscoped. + projects = unscoped. joins(:namespace). - iwhere('namespaces.path' => namespace_path). - iwhere('projects.path' => project_path). - take + iwhere('namespaces.path' => namespace_path) + + projects.where('projects.path' => project_path).take || + projects.iwhere('projects.path' => project_path).take end def visibility_levels |
