logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe
commit: 6a82939adb823c9a65829c23dc7109a96480befe
parent: 98aa96b8d6800f049e6b185b15a6c215042b8f08
Author: Andrea Scarpino <scarpino@kde.org>
Date:   Sun, 10 Dec 2017 19:35:46 +0100

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

* Strip leading & trailing spaces from account query

* Strip leading & trailing spaces from tag search

Diffstat:

Mapp/models/tag.rb2+-
Mapp/services/account_search_service.rb2+-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/app/models/tag.rb b/app/models/tag.rb @@ -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 diff --git a/app/services/account_search_service.rb b/app/services/account_search_service.rb @@ -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