From c92428617cd83d80085c85e934da651200c8ee8c Mon Sep 17 00:00:00 2001 From: Daniel Nitsikopoulos Date: Sat, 18 Feb 2023 16:53:46 +1100 Subject: [PATCH] fixup! Add web mentions --- lib/adamantium/link_finder.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 lib/adamantium/link_finder.rb diff --git a/lib/adamantium/link_finder.rb b/lib/adamantium/link_finder.rb new file mode 100644 index 0000000..86e1f36 --- /dev/null +++ b/lib/adamantium/link_finder.rb @@ -0,0 +1,21 @@ +require "uri" + +module Adamantium + class LinkFinder + IGNORE_LIST = %w[twitter.com + instagram.com + google.com + overcast.fm + youtube.com + github.com] + + def call(content) + links = URI::DEFAULT_PARSER.extract(content) + + links.reject do |link| + link.end_with?(":") || + IGNORE_LIST.include?(URI.parse(link).host) + end + end + end +end