]> cat aescling's git repositories - mastodon.git/commitdiff
Fix #288 - Strip first @ from search query, don't search accounts if it begins with #
authorEugen Rochko <eugen@zeonfederated.com>
Sat, 26 Nov 2016 14:32:29 +0000 (15:32 +0100)
committerEugen Rochko <eugen@zeonfederated.com>
Sat, 26 Nov 2016 14:32:29 +0000 (15:32 +0100)
app/services/search_service.rb

index 598c7d02c4f7a1c4275f08d59668112f75074edd..1ae1d5a805c788d131092bf9ea7dc23a690f6995 100644 (file)
@@ -2,9 +2,9 @@
 
 class SearchService < BaseService
   def call(query, limit, resolve = false)
-    return if query.blank?
+    return if query.blank? || query.start_with?('#')
 
-    username, domain = query.split('@')
+    username, domain = query.gsub(/\A@/, '').split('@')
 
     results = if domain.nil?
                 Account.search_for(username)