]> cat aescling's git repositories - mastodon.git/commitdiff
Fix account and tag searches with leading/trailing spaces (#5965)
authorAndrea Scarpino <scarpino@kde.org>
Sun, 10 Dec 2017 18:35:46 +0000 (19:35 +0100)
committerEugen Rochko <eugen@zeonfederated.com>
Sun, 10 Dec 2017 18:35:46 +0000 (19:35 +0100)
* Strip leading & trailing spaces from account query

* Strip leading & trailing spaces from tag search

app/models/tag.rb
app/services/account_search_service.rb

index 0fa08e157c831d224dec5e67349751af2440f698..dc2c8d12907b35351798befedd28b8f42e0afb8e 100644 (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
index a289ceac4fcd322d2ffde10b096569b16765bae7..3be110665404572c5f321aef515ac522134e8b45 100644 (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