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!