Fix account and tag searches with leading/trailing spaces (#5965)

* Strip leading & trailing spaces from account query

* Strip leading & trailing spaces from tag search
lolsob-rspec
Andrea Scarpino 2017-12-10 19:35:46 +01:00 committed by Eugen Rochko
parent 188f230f1e
commit e8198cd298
2 changed files with 2 additions and 2 deletions

View File

@ -23,7 +23,7 @@ class Tag < ApplicationRecord
class << self
def search_for(term, limit = 5)
pattern = sanitize_sql_like(term) + '%'
pattern = sanitize_sql_like(term.strip) + '%'
Tag.where('lower(name) like lower(?)', pattern).order(:name).limit(limit)
end
end

View File

@ -4,7 +4,7 @@ class AccountSearchService < BaseService
attr_reader :query, :limit, :options, :account
def call(query, limit, account = nil, options = {})
@query = query
@query = query.strip
@limit = limit
@options = options
@account = account