mirror of
https://github.com/discourse/discourse.git
synced 2025-06-20 15:46:23 +08:00
DEV: tag:
filter on /filter
only supported alphabets and numbers (#21405)
A tag's name can consist of any Unicode characters as well
This commit is contained in:

committed by
GitHub

parent
6f26732551
commit
7d0ef338e4
@ -363,7 +363,7 @@ class TopicsFilter
|
|||||||
break if key_prefix && key_prefix != "-"
|
break if key_prefix && key_prefix != "-"
|
||||||
|
|
||||||
value.scan(
|
value.scan(
|
||||||
/\A(?<tag_names>([a-zA-Z0-9\-]+)(?<delimiter>[,+])?([a-zA-Z0-9\-]+)?(\k<delimiter>[a-zA-Z0-9\-]+)*)\z/,
|
/\A(?<tag_names>([\p{N}\p{L}\-]+)(?<delimiter>[,+])?([\p{N}\p{L}\-]+)?(\k<delimiter>[\p{N}\p{L}\-]+)*)\z/,
|
||||||
) do |tag_names, delimiter|
|
) do |tag_names, delimiter|
|
||||||
match_all =
|
match_all =
|
||||||
if delimiter == ","
|
if delimiter == ","
|
||||||
|
@ -869,6 +869,19 @@ RSpec.describe TopicsFilter do
|
|||||||
.pluck(:id),
|
.pluck(:id),
|
||||||
).to contain_exactly(topic_without_tag.id, topic_with_group_only_tag.id)
|
).to contain_exactly(topic_without_tag.id, topic_with_group_only_tag.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "when query string is tag:日べé1" do
|
||||||
|
before { tag.update!(name: "日べé1") }
|
||||||
|
|
||||||
|
it "should return topics that are tagged with the specified tag" do
|
||||||
|
expect(
|
||||||
|
TopicsFilter
|
||||||
|
.new(guardian: Guardian.new)
|
||||||
|
.filter_from_query_string("tag:日べé1")
|
||||||
|
.pluck(:id),
|
||||||
|
).to contain_exactly(topic_with_tag.id, topic_with_tag_and_tag2.id)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "when filtering by topic author" do
|
describe "when filtering by topic author" do
|
||||||
|
Reference in New Issue
Block a user