Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2017-08-10 14:09:08 +0300
committerSean McGivern <sean@mcgivern.me.uk>2017-08-10 14:09:08 +0300
commit4c7ada21c0502879ae8700225723043df864c490 (patch)
treea15f4fce04c133d9b47ef02f3f1f7017430dcd0f /app
parent53ee38053cb924b57447e385dee2a45b8e759ff5 (diff)
parent3d58e30b6b5b6bbd25fcb4f59650250ee9eb83fb (diff)
Merge branch 'mk-fix-case-insensitive-redirect-matching' into 'master'
Fix conflicting redirect search See merge request !13357
Diffstat (limited to 'app')
-rw-r--r--app/models/redirect_route.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/app/models/redirect_route.rb b/app/models/redirect_route.rb
index 964175ddab8..090fbd61e6f 100644
--- a/app/models/redirect_route.rb
+++ b/app/models/redirect_route.rb
@@ -8,5 +8,13 @@ class RedirectRoute < ActiveRecord::Base
presence: true,
uniqueness: { case_sensitive: false }
- scope :matching_path_and_descendants, -> (path) { where('redirect_routes.path = ? OR redirect_routes.path LIKE ?', path, "#{sanitize_sql_like(path)}/%") }
+ scope :matching_path_and_descendants, -> (path) do
+ wheres = if Gitlab::Database.postgresql?
+ 'LOWER(redirect_routes.path) = LOWER(?) OR LOWER(redirect_routes.path) LIKE LOWER(?)'
+ else
+ 'redirect_routes.path = ? OR redirect_routes.path LIKE ?'
+ end
+
+ where(wheres, path, "#{sanitize_sql_like(path)}/%")
+ end
end