mirror of
https://github.com/discourse/discourse.git
synced 2025-03-22 10:05:33 +08:00
FIX: support non-english tags in tag input field
This commit is contained in:
parent
6f09df0deb
commit
a509146ea5
@ -64,9 +64,8 @@ module DiscourseTagging
|
|||||||
def self.filter_allowed_tags(query, guardian, opts={})
|
def self.filter_allowed_tags(query, guardian, opts={})
|
||||||
term = opts[:term]
|
term = opts[:term]
|
||||||
if term.present?
|
if term.present?
|
||||||
term.downcase!
|
|
||||||
term.gsub!(/[^a-z0-9\.\-\_]*/, '')
|
|
||||||
term.gsub!("_", "\\_")
|
term.gsub!("_", "\\_")
|
||||||
|
term = clean_tag(term)
|
||||||
query = query.where('tags.name like ?', "%#{term}%")
|
query = query.where('tags.name like ?', "%#{term}%")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -130,6 +130,21 @@ describe TagsController do
|
|||||||
json = ::JSON.parse(response.body)
|
json = ::JSON.parse(response.body)
|
||||||
expect(json["results"].map{|j| j["id"]}).to eq(['cooltag'])
|
expect(json["results"].map{|j| j["id"]}).to eq(['cooltag'])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "supports Chinese and Russian" do
|
||||||
|
tag_names = ['房地产', 'тема-в-разработке']
|
||||||
|
tag_names.each { |name| Fabricate(:tag, name: name) }
|
||||||
|
|
||||||
|
xhr :get, :search, q: '房'
|
||||||
|
expect(response).to be_success
|
||||||
|
json = ::JSON.parse(response.body)
|
||||||
|
expect(json["results"].map{|j| j["id"]}).to eq(['房地产'])
|
||||||
|
|
||||||
|
xhr :get, :search, q: 'тема'
|
||||||
|
expect(response).to be_success
|
||||||
|
json = ::JSON.parse(response.body)
|
||||||
|
expect(json["results"].map{|j| j["id"]}).to eq(['тема-в-разработке'])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user