autocomplete: match static metatags case-sensitively.

Fix rating:S not matching rating:s.
This commit is contained in:
evazion
2021-02-25 06:12:24 -06:00
parent 6ff648e40b
commit 1b93cbd075
2 changed files with 7 additions and 1 deletions

View File

@@ -161,7 +161,7 @@ class AutocompleteService
def autocomplete_static_metatag(metatag, value)
values = STATIC_METATAGS[metatag.to_sym]
results = values.select { |v| v.starts_with?(value) }.sort.take(limit)
results = values.select { |v| v.starts_with?(value.downcase) }.sort.take(limit)
results.map do |v|
{ label: metatag + ":" + v, value: v }

View File

@@ -201,6 +201,12 @@ class AutocompleteServiceTest < ActiveSupport::TestCase
assert_autocomplete_equals(["order:score", "order:score_asc"], "order:sco", :tag_query)
end
should "match static metatags case-insensitively" do
assert_autocomplete_equals(["rating:safe"], "rating:S", :tag_query)
assert_autocomplete_equals(["rating:questionable"], "rating:Q", :tag_query)
assert_autocomplete_equals(["rating:explicit"], "rating:E", :tag_query)
end
should "ignore bogus tags" do
assert_autocomplete_equals([], "x"*200, :tag_query)
assert_autocomplete_equals([], "http://www.google.com", :tag_query)