about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-07-19 19:28:56 -0500
committermultiple creatures <dev@multiple-creature.party>2019-07-19 19:30:59 -0500
commit2f8ac8838da4af3de8885b0b4ee88729eb9f4ca0 (patch)
treead9d8fe97693f95c1c58502099d5ad52580436fb /app
parent9b7e4018b085dc70d9261173a64e167e0166c94b (diff)
revise tag conversion
Diffstat (limited to 'app')
-rw-r--r--app/services/post_status_service.rb16
1 files changed, 7 insertions, 9 deletions
diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb
index ea7a2c2c3..3bb580508 100644
--- a/app/services/post_status_service.rb
+++ b/app/services/post_status_service.rb
@@ -104,15 +104,13 @@ class PostStatusService < BaseService
 
   # move tags out of body so we can format them later
   def extract_tags
-    chunks = []
-    @text.split(/^((?:#[\w:._·\-]+\s*)+)/).each do |chunk|
-      if chunk.match?(/\A#[\w:._·\-]/)
-        @tags |= chunk.strip.gsub('#', '').split(/\s+/)
-      else
-        chunks << chunk
-      end
-    end
-    @text = chunks.join
+    @text.gsub!(/^##/, "\uf666")
+    @text.gsub!('##', "\uf669")
+    @tags |= Extractor.extract_hashtags(@text)
+    @text.strip!
+    @text.gsub!(/^(?:#[\w:._·\-]+\s*)+|(?:#[\w:._·\-]+\s*)+\Z/, '')
+    @text.gsub!("\uf669", "##")
+    @text.gsub!("\uf666", "#")
   end
 
   def preprocess_attributes!