about summary refs log tree commit diff
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-07-17 16:51:26 -0500
committermultiple creatures <dev@multiple-creature.party>2019-07-17 16:51:26 -0500
commit6bffa5647355ef7924d32e760ee001bee5b45ebc (patch)
treec3c2b424a3eda6a99c6cdbbb54759ca292767821
parent65b79ae1886eeb3cc713b1646c1ae8debbd7b050 (diff)
add `parent:urls` & `parent:domains` bangtags
-rw-r--r--app/lib/bangtags.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/app/lib/bangtags.rb b/app/lib/bangtags.rb
index c8e64d30c..150150f75 100644
--- a/app/lib/bangtags.rb
+++ b/app/lib/bangtags.rb
@@ -310,6 +310,16 @@ class Bangtags
                 ours.save
               end
             end
+          when 'urls'
+            plain = @parent_status.text.gsub(/(<br \/>|<br>|<\/p>)+/) { |match| "#{match}\n" }
+            plain = ActionController::Base.helpers.strip_tags(plain)
+            plain.gsub!(/ dot /i, '.')
+            chunk = plain.scan(/https?:\/\/[\w\-]+\.[\w\-]+(?:\.[\w\-]+)*/).uniq.join(' ')
+          when 'domains'
+            plain = @parent_status.text.gsub(/(<br \/>|<br>|<\/p>)+/) { |match| "#{match}\n" }
+            plain = ActionController::Base.helpers.strip_tags(plain)
+            plain.gsub!(/ dot /i, '.')
+            chunk = plain.scan(/[\w\-]+\.[\w\-]+(?:\.[\w\-]+)*/).uniq.join(' ')
           end
         when 'media'
           chunk = nil