Commit e17e5a5c authored by Douwe Maan's avatar Douwe Maan
Browse files

Move case sensitivity check to find_with_namespace.

parent 32b1b5420579
...@@ -118,8 +118,7 @@ def project ...@@ -118,8 +118,7 @@ def project
end end
project_path = "#{namespace}/#{id}" project_path = "#{namespace}/#{id}"
@project = Project.find_with_namespace(project_path) || @project = Project.find_with_namespace(project_path)
Project.find_with_namespace(project_path, case_sensitive: false)
if @project and can?(current_user, :read_project, @project) if @project and can?(current_user, :read_project, @project)
if @project.path_with_namespace != project_path if @project.path_with_namespace != project_path
......
...@@ -235,7 +235,7 @@ def search_by_title(query) ...@@ -235,7 +235,7 @@ def search_by_title(query)
where('projects.archived = ?', false).where('LOWER(projects.name) LIKE :query', query: "%#{query.downcase}%") where('projects.archived = ?', false).where('LOWER(projects.name) LIKE :query', query: "%#{query.downcase}%")
end end
def find_with_namespace(id, case_sensitive: true) def find_with_namespace(id)
namespace_path, project_path = id.split('/') namespace_path, project_path = id.split('/')
return nil if !namespace_path || !project_path return nil if !namespace_path || !project_path
...@@ -247,14 +247,8 @@ def find_with_namespace(id, case_sensitive: true) ...@@ -247,14 +247,8 @@ def find_with_namespace(id, case_sensitive: true)
joins(:namespace). joins(:namespace).
iwhere('namespaces.path' => namespace_path) iwhere('namespaces.path' => namespace_path)
projects = projects.where('projects.path' => project_path).take ||
if case_sensitive projects.iwhere('projects.path' => project_path).take
projects.where('projects.path' => project_path)
else
projects.iwhere('projects.path' => project_path)
end
projects.take
end end
def visibility_levels def visibility_levels
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment