diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-08-10 11:09:08 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-08-10 11:09:08 +0000 |
commit | 4c7ada21c0502879ae8700225723043df864c490 (patch) | |
tree | a15f4fce04c133d9b47ef02f3f1f7017430dcd0f /app | |
parent | 53ee38053cb924b57447e385dee2a45b8e759ff5 (diff) | |
parent | 3d58e30b6b5b6bbd25fcb4f59650250ee9eb83fb (diff) | |
download | gitlab-ce-4c7ada21c0502879ae8700225723043df864c490.tar.gz |
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.rb | 10 |
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 |