From a3caf63a53a39b0fe9049a1f4dd2f4e57bb75789 Mon Sep 17 00:00:00 2001 From: Miles Zhang Date: Thu, 2 Jan 2025 17:43:41 +0900 Subject: [PATCH] fix: nft suspicious tag logic (#2381) Signed-off-by: Miles Zhang --- app/workers/token_collection_tag_worker.rb | 2 +- test/workers/token_collection_tag_worker_test.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/workers/token_collection_tag_worker.rb b/app/workers/token_collection_tag_worker.rb index 7d05e86d8..9fcfdb2a3 100644 --- a/app/workers/token_collection_tag_worker.rb +++ b/app/workers/token_collection_tag_worker.rb @@ -35,7 +35,7 @@ def invalid_char?(name) end def invisible_char?(name) - (name =~ /^[\x21-\x7E\u4E00-\u9FFF]+(?:\s[\x21-\x7E\u4E00-\u9FFF]+)?$/).nil? + (name =~ /^[\x21-\x7E\u4E00-\u9FFF]+(?:\s[\x21-\x7E\u4E00-\u9FFF]+)*$/).nil? end def out_of_length?(name) diff --git a/test/workers/token_collection_tag_worker_test.rb b/test/workers/token_collection_tag_worker_test.rb index 6c652abd5..aaf4a162d 100644 --- a/test/workers/token_collection_tag_worker_test.rb +++ b/test/workers/token_collection_tag_worker_test.rb @@ -19,6 +19,12 @@ class TokenCollectionTagWorkerTest < ActiveJob::TestCase assert_equal ["suspicious"], TokenCollection.last.tags end + test "add suspicious tag to token_collection when blanks are not continuous" do + create(:token_collection, name: "C K B B", cell_id: @cell.id, creator_id: @address.id) + TokenCollectionTagWorker.new.perform + assert_equal ["rgb++", "layer-1-asset"], TokenCollection.last.tags + end + test "add out-of-length-range tag to token_collection" do create(:token_collection, name: "C" * 66, cell_id: @cell.id, creator_id: @address.id) TokenCollectionTagWorker.new.perform