tag aliases: fix bug in alias resolution.
Bug: Searching for an aliased tag returns an empty page instead of
showing the results for the real tag.
Cause: The query parsing code runs the search string through
`.mb_chars.downcase` before calling `TagAlias.to_aliased`, so the input
to `to_aliased` is actually a ActiveSupport::Multibyte::Chars object.
This breaks the `aliases[name]` hash lookup because `name` is not a
plain string.
Fixup for c7bcce429.
This commit is contained in:
@@ -44,8 +44,8 @@ class TagAlias < TagRelationship
|
||||
end
|
||||
|
||||
def self.to_aliased(names)
|
||||
names = Array(names)
|
||||
return names if names.empty?
|
||||
names = Array(names).map(&:to_s)
|
||||
return [] if names.empty?
|
||||
aliases = active.where(antecedent_name: names).map { |ta| [ta.antecedent_name, ta.consequent_name] }.to_h
|
||||
names.map { |name| aliases[name] || name }
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user